Skip to content

Instantly share code, notes, and snippets.

@romain9292
Created August 12, 2022 15:10
Show Gist options
  • Save romain9292/a2fd45119112cbe935672db7d80b5fcf to your computer and use it in GitHub Desktop.
Save romain9292/a2fd45119112cbe935672db7d80b5fcf to your computer and use it in GitHub Desktop.
[Perc Total - Over time - Part 1] How to compute a percentage of total in BigQuery using SQL #SQL #BigQuery
WITH
revenue_product AS (
SELECT
product_category,
DATE(DATE_TRUNC(order_date,MONTH)) AS order_month,
ROUND(SUM(product_revenue),0) AS revenue_per_category
FROM
`datastic.variables.base_table`
GROUP BY
1,
2)
-- Main Query
SELECT
*
FROM
revenue_product
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment