daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Select A.col1, sum(A.metric1) over (partition by A.col1, B.col1 order by A.col2 asc) as Cust_col, B.col1 from A JOIN B on (A.join_key=B.join_key) where A.col3='X' QUALIFY ROW_NUMBER () OVER (PARTITION BY A.col1,B.COL1 ORDER BY A.col3 DESC) = 1
  2.      
  3. Select C.col1,C.cust_col,C.col1,ROW_NUMBER () OVER (PARTITION BY A.col1,C.COL1 ORDER BY C.col3 DESC) as Row_num from (Select A.col1, sum(A.metric1) over (partition by A.col1, B.col1 order by A.col2 asc) as Cust_col,B.col1 from A JOIN B on (A.join_key=B.join_key) where A.col3='X') C where C.ROW_NUM=1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top