Snowflake Vs MS-SQL - Part 46 - RATIO_TO_REPORT

           


RATIO_TO_REPORT

If you have a table in which amounts are present and you want to calculate the percentage distribution of those amounts as below:

+----------+--------+----------------+
| STORE_ID | PROFIT | PERCENT_PROFIT |
|----------+--------+----------------|
|        1 | 500.00 |    42          |
|        2 | 250.00 |    21          |
|        3 | 450.00 |    38          |
|        4 |   NULL |    NULL        |
+----------+--------+----------------+

MS-SQL Server 

Using the SUM function and OVER clause, you can achieve the above output as below:



In Snowflake, we can use a similar approach as above. However, Snowflake has a different function RATIO_TO_REPORT



For more details, you can refer to the following Ratio_To_Report.




Yogesh Shinde

LinkedInProfile

<<< Back Next >>>

Comments

Popular posts from this blog

Snowflake Vs MS-SQL - Part 36 - SPLIT_TO_TABLE

Snowflake Vs MS-SQL - Part 63 - ON Clause & Cross Join

Snowflake Vs MS-SQL - Part 33 - INITCAP