The standard aggregation method sum
can be applied to numeric values to return the sum of the non-null values, or null if there are no non-null values.
For example, to sum the DocRate
of the Orders, send a request like:
GET /b1s/v1/Orders?$apply=aggregate(DocRate with sum as TotalDocRate)
On success, the response is like:
The equivalent SQL on HANA is:
SELECT SUM(T0."DocRate") AS "TotalDocRate" FROM "ORDR" T0
The standard aggregation method average
can be applied to numeric values to return the sum of the non-null values divided by the count of the non-null values, or null if there are no non-null values.
For example, to calculate the average VatSum
of the Orders, send a request like:
GET /b1s/v1/Orders?$apply=aggregate(VatSum with average as AvgVatSum )
On success, the response is like:
The equivalent SQL on HANA is:
SELECT AVG(T0."VatSum") AS "AvgVatSum" FROM "ORDR" T0
The standard aggregation method max
can be applied to values with a totally ordered domain to return the largest of the non-null values, or null if there are no non-null values. The result property will have the same type as the input property.
For example, to get the maximum DocEntry
of the Orders, send a request like:
GET /b1s/v1/Orders?$apply=aggregate(DocEntry with max as MaxDocEntry)
On success, the response is like:
The equivalent SQL on SAP HANA is:
SELECT MAX(T0."DocEntry") AS "MaxDocEntry" FROM "ORDR" T0
The standard aggregation method min
can be applied to values with a totally ordered domain to return the smallest of the non-null values, or null if there are no non-null values. The result property will have the same type as the input property.
For example, to get the minimum DocEntry
of the Orders, send a request like:
GET/b1s/v1/Orders?$apply=aggregate(DocEntry with min as MinDocEntry)
On success, the response is like:
The equivalent SQL on SAP HANA is:
SELECT MIN(T0."DocEntry") AS "MinDocEntry" FROM "ORDR" T0
The aggregation method countdistinct
counts the distinct values, omitting any null values.
For example, to count the distinct CardCode
of the Orders, send a request like:
GET /b1s/v1/Orders?$apply=aggregate(CardCode with countdistinct as CountDistinctCardCode )
On success, the response is like:
The equivalent SQL on SAP HANA is:
SELECT COUNT(DISTINCT T0."CardCode") AS "CountDistinctCardCode" FROM "ORDR" T0
The value of the virtual property $count
is the number of instances in the input set. It MUST always specify an alias and MUST NOT specify an aggregation method.
For example, to count the number of Orders, send a request like:
GET /b1s/v1/Orders?$apply=aggregate($count as OrdersCount)
On success, the response is like:
The equivalent SQL on SAP HANA is:
SELECT COUNT(T0."DocEntry") AS "OrdersCount" FROM "ORDR" T0
[Note] Aggregation combined with filter also works, as illustrated in the following examples:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
11 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |