Query with Aggregate

Operation like sum, average, minimum and maximum of a set of data points is required while building a dashboard. This is one of the most common use case when you want to build a dashboard.

Sample Dataset

For example, we have sample dataset of orders placed on a hypothetical ecommerce store. This dataset has the following fields.

FieldData Type
orderIdInteger
amountFloat
createOnTimestamp
saleSourceString (Possible values: ONLINE, OFFLINE)
sellerIdInteger
statusString (Possible values: ON_HOLD, CONFIRMED)
userIdInteger

Maximum operator

Let's say we want to find the maximum value of a column. To create this GraphQL query first pick the root query q. All the analytics queries in dingoql starts with q.

Then we have to pick the table, in three steps.

  1. Pick datasource (or we can call this database as well.)
  2. Pick the schema inside this datasource.
  3. Pick the table inside this chosen schema.

We do this for every analytics query we want to execute in dingoql.

Now we can create a SUM query by setting the input field metric as follows (Please feel free experiment with live GraphQL query editor below.)

Query Variables

The response can be found in the jsonData field.

Other operators

Similarily we can execute min operator as well.

Query Variables

All Available Aggregate operators

  1. SUM
  2. MAX - maximum
  3. MIN - minimum
  4. AVG - average
  5. COUNT

Distinct Operator

In some cases we might want to apply a distinct operation on a column of a dataset while we are doing an aggregate operation. For example, let's set we want to answer the questions, how many possible states are there for an order? We can answer this by using distinct operator as follows

Query Variables

Alias

Aggregate query result is can be found jsonData field in a key which follows the follows the pattern <OPERATOR_NAME>_<FIELD_NAME>. If you wish to rename this then it can be done by providing an alias field as follows

Query Variables