Modern SQL engines have a wealth of aggregation functions.
Here's a quick example that makes use ofBigQuery STRING_AGG.
What does it do?
It aggregates all the values in a grouping, joined by a separator of our choice, creating a string of those joined values.
We can of course choose to:
➡️ keep only distinct values, as well as
➡️ order the values in the newly created string
so that, as in the below example, ("Card", "Cash") and ("Cash", "Card") both produce "Card~Cash", every time.
Any interesting aggregation function that you use in your SQL dialect?
Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.