-2
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
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Akhira
  • 203
  • 2
  • 5
  • 16

1 Answers1

0

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 |
+----------+--------+----------------+

Mike Gohl
  • 627
  • 4
  • 7