Please enable JavaScript.
Coggle requires JavaScript to display documents.
Aggregated Query Tree - Coggle Diagram
Aggregated Query Tree
Aggregate Functions (Group Functions)
COUNT
COUNT(col)
COUNT(*) - count by number of rows
MIN
Minimum number, ascii, earliest
Used for any data type
MAX
SUM
AVR
ROUND
Default decimal is 0 if omitted
VARIANCE
STDDEV
Used for num data type only
groupFunction(col)
Common Properties
written in SELECT only
ignore NULL values
can be multipled or nested
summarize info
give one result per group from sets of rows
GROUP BY
divide rows into smaller groups
can be GROUP BY multiple cols
group first before calling group functions
All of non-grouped cols selected must be included
Good Habit: SELECT necessary cols only
diff seq, diff grouping result
HAVING
to restrict groups
focus on each & every col