如何在雪花查询中使用百分比关键字 [英] How to use the percent key word in the snowflake query

查看:82
本文介绍了如何在雪花查询中使用百分比关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT  NBR, Customers, status
FROM (
  SELECT  NBR, Customers, Code AS status
  FROM   CCC AS CS 
  INNER JOIN AAA AS AC ON CCC.B2= ACT.B1 AND CSS.B2 = ACT.B1
) AS rst
WHERE status IN ('A', 'T')
ORDER BY NBR LIMIT 100 PERCENT

推荐答案

我看到了其他帖子.不能100%地确定要执行的操作,但是您可能要考虑使用诸如ratio_to_report之类的Windows函数.请参见下面的示例.这是Windows功能的链接

I saw you other post. Not 100% sure what you are trying to do, but you might want to consider using a windows function like ratio_to_report. See the example below. Here is a link to the windows functions

https://docs.snowflake.net/manuals/sql -reference/functions-analytic.html

select 
        store_id, profit, 
        100 * ratio_to_report(profit) over () as percent_profit
    from store_profit
    order by store_id;
+----------+--------+----------------+
| STORE_ID | PROFIT | PERCENT_PROFIT |
|----------+--------+----------------|
|        1 | 300.00 |    30.00000000 |
|        2 | 250.00 |    25.00000000 |
|        3 | 450.00 |    45.00000000 |
|        4 |   NULL |           NULL |
+----------+--------+----------------+

这篇关于如何在雪花查询中使用百分比关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆