Skip to content
Developerhome

Query with aggregation

  Less than to read

The following table displays an example and the result of a query to compute an aggregated list based on criteria with group compute values. Some of the fields displayed are not mandatory and others have been omitted.

{ 
    xtremMasterData { 
        itemSiteCost { 
            queryAggregate(first: 3, 
            orderBy: "{itemSite:{item:{description:+1}}}") { 
                edges { 
                    node { 
                        group { 
                            itemSite { 
                                item { 
                                    id 
                                    description 
                                } 
                            } 
                        } 
                        values { 
                            itemSite { 
                                site { 
                                    name { 
                                        distinctCount 
                                    } 
                                } 
                            } 
                            unitCost { 
                                avg 
                                min 
                                max 
                            } 
                        } 
                    } 
                } 
            } 
        } 
    } 
}
{ 
    "data": { 
        "xtremMasterData": { 
            "itemSiteCost": { 
                "queryAggregate": { 
                    "edges": [ 
                        {
                            "node": { 
                                "group": { 
                                    "itemSite": { 
                                        "item": { 
                                            "id": "FST09YA", 
                                            "description": " Capteur" 
                                        } 
                                    } 
                                }, 
                                "values": { 
                                    "itemSite": { 
                                        "site": { 
                                            "name": { 
                                                "distinctCount": 1 
                                            } 
                                        } 
                                    }, 
                                    "unitCost": { 
                                        "avg": "12", 
                                        "min": "12", 
                                        "max": "12" 
                                    } 
                                } 
                            } 
                        }, 
                    ]
                }
            }
        }
    }
} 

The above example groups the itemSiteCost record by item description in ascending order. It also counts the number of distinct sites where this item is referenced, and the minimum, maximum and average cost for the item.