Created
August 12, 2022 15:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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