aggregating data
TRANSCRIPT
Aggregating Data
Presented by Aaron Buma
AgendaCOUNT(), SUM(), MIN(), MAX(), AVG()
Accounting for NULLsGrouping on multiple fieldsOrdering Results
HAVING – Filtering on Aggregate fieldsFiltering on Aggregate and non-aggregate
fieldsDISTINCT
COUNT(), SUM(), MIN(), MAX(), AVG()function(expression) – Expressions generally column
nameCOUNT(x) – number of matching records, can be *, 1,
columnSUM(x) – summation of expression or column per groupMIN(x) – minimum of expression value per groupMAX(x) – maximum of expression value per groupAVG(x) – average of expression value per group
Aggregation DetailsAccounting for NULLsGrouping on Multiple FieldsORDER BY on Aggregate Fields
HAVING - Filtering on Aggregate FieldsThe ‘HAVING’ clauseIncluding non-Aggregate field in filtering
DISTINCT - Filtering on Aggregate FieldsThe ‘DISTINCT’ clause
How to include with COUNT(), MIN(), MAX(), AVG()Does it account for NULLS?
Question 1
SELECT DateRecorded,VoteID,COUNT(User) AS [Count]
FROM VoterTable GROUP BY DateRecord,
VoteID;
Question 2Total Cost of inventory on hand?
Question 2
Any Questions?COUNT(), SUM(), MIN(), MAX(), AVG()
Accounting for NULLsGrouping on multiple fieldsOrdering Results
HAVING – Filtering on Aggregate fieldsFiltering on Aggregate and non-aggregate
fieldsDISTINCT