sql-aggregates Flashcards
1
Q
What are some examples of aggregate functions?
A
max(), sum(), min(), every(), count(), json.agg()
2
Q
What is the purpose of a group by clause?
A
To separate rows into groups and perform aggregate functions on those groups of rows. Partitions the results by the part you don’t want duplicates of.
3
Q
What is the rule for select and group by for aggregate functions
A
Columns from select that are not aggregate functions need to appear in group by unless you can replace that column by a unique id.