I've previously shared how aggregate functions in BQ #SQL can pick their rows with HAVING MAX / HAVING MIN. WHERE is now supported in preview (yes, I'm the ten...
I've previously shared how aggregate functions in BQ #SQL can pick their rows with HAVING MAX / HAVING MIN.
WHERE is now supported in preview (yes, I'm the tenth person posting it). It filters the input rows, so any aggregate can run on any subset of the data. The difference: HAVING MAX picks the extreme rows of the group; WHERE picks rows by conditions you know beforehand.
Sure, you could solve most of this before with SUM(CASE WHEN ... END), a classic SQL interview question. To me, a WHERE like this is more intuitive and pleasing to the eye. Very #BigQuery.
Link to previous post in comments.
28
I cookie ti permettono di navigare in modo ottimale su questo sito e di personalizzare l'esperienza di navigazione.