Thursday, October 11, 2018

Sample AGGREGATE SQL function and GROUP BY statement in ODBC

The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns. Aggregate functions often need an added Group By statement.
 
SYNTAX
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name

SELECT ENTITY_ID,
             SUM(AMOUNT_UNBILLED)
FROM TRANSACTIONS
WHERE TRANSACTION_TYPE = 'Sales Order'
GROUP BY ENTITY_ID

No comments:

Post a Comment