Grouping Fields

February 02, 2015
By Bounteous

Legacy SQL

SELECT
     fullVisitorId AS Client_ID,
     SUM(totals.pageviews) AS Pageviews,
     COUNT(visitId) AS Sessions
FROM   
     [google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
GROUP BY
     Client_ID
ORDER BY
     Pageviews DESC
LIMIT 5

Standard SQL

SELECT
     fullVisitorId AS Client_ID,
     SUM(totals.pageviews) AS Pageviews,
     COUNT(visitId) AS Sessions
FROM   
     'google.com:analytics-bigquery.LondonCycleHelmet.ga_sessions_20130910'
GROUP BY
     Client_ID
ORDER BY
     Pageviews DESC
LIMIT 5