22 Sep 19 · npack ·       Add to Favorites  

GROUP BY clause syntax in Google Bigquery

The GROUP BY clause groups together rows in a table with non-distinct values for the expression in the GROUP BY clause. For multiple rows in the source table with non-distinct values for expression, the GROUP BY clause produces a single combined row. GROUP BY is commonly used when aggregate functions are present in the SELECT list, or to eliminate redundancy in the output. The data type of expression must be groupable

SELECT SUM(PointsScored), LastName
FROM PlayerStats
GROUP BY LastName;

The GROUP BY clause also allows ordinal references to expressions in the SELECT list using integer values

SELECT SUM(PointsScored), LastName, FirstName
FROM PlayerStats
GROUP BY 2, 3;

npack

posted on 22 Sep 19

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds

Copied