This file contains hidden or 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
| SELECT | |
| *, | |
| ROUND(PERCENT_RANK() OVER(ORDER BY revenue)*100,2) AS pct_rank, | |
| FROM | |
| `datastic.ranking.base_table`; |
This file contains hidden or 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
| SELECT | |
| *, | |
| NTILE(4) OVER(ORDER BY revenue) AS quartiles, | |
| FROM | |
| `datastic.ranking.base_table`; |
This file contains hidden or 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
| SELECT | |
| *, | |
| ROUND(CUME_DIST() OVER(ORDER BY revenue),2)*100 AS cumulative_distribution, | |
| FROM | |
| `datastic.ranking.base_table`; |
This file contains hidden or 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
| SELECT | |
| *, | |
| ROW_NUMBER() OVER(ORDER BY revenue DESC) AS row_number, | |
| RANK() OVER(ORDER BY revenue DESC) AS rank, | |
| DENSE_RANK() OVER(ORDER BY revenue DESC) AS dense_rank, | |
| FROM | |
| `datastic.ranking.base_table`; |
This file contains hidden or 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
| SELECT | |
| *, | |
| ROW_NUMBER() OVER(PARTITION BY product_category ORDER BY revenue DESC) AS row_number | |
| FROM | |
| `datastic.ranking.base_table`; |
This file contains hidden or 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
| SELECT | |
| *, | |
| ROW_NUMBER() OVER(ORDER BY revenue DESC) AS row_number | |
| FROM | |
| `datastic.ranking.base_table`; |
This file contains hidden or 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
| SELECT | |
| *, | |
| ROW_NUMBER() OVER() AS row_number | |
| FROM | |
| `datastic.ranking.base_table` |
This file contains hidden or 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, |
This file contains hidden or 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, |
NewerOlder