Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

row concatenation for dummies? AKA oracle wm_concat() teradata equivalent - response (10) by Jessy Mahesh Kothapalli

$
0
0

Hi Rajeev/KS,
           
                 We've achived it by using COALESCE function.
 
WITH RECURSIVE RSLT (DEALER_WID,DIVN_WID, EVTLOC_WID,MONTH_WID,LM_WID,LLM_WID,MM_WID, EVENT_NAME,C0_QTY,LVL)
 

AS(

SEL DEALER_WID,DIVN_WID, EVTLOC_WID,MONTH_WID,LM_WID,LLM_WID,MM_WID,CAST ( EVENT_NAME  AS VARCHAR(1000)),C0_QTY,1 AS LVL

FROM  DEV_ETL_USER.M1

WHERE RN1 = 1

 

UNION ALL

SEL

B.DEALER_WID,

B.DIVN_WID, 

B.EVTLOC_WID,

--B.MONTH_WID,

B.MONTH_WID,

B.LM_WID,

B.LLM_WID,

B.MM_WID,

C2.EVENT_NAME || ',' ||B.EVENT_NAME ,

B.C0_QTY,

B.RN1

FROM  DEV_ETL_USER.M1  B INNER JOIN RSLT C2

ON

C2.DEALER_WID=B.DEALER_WID

AND C2.DIVN_WID=B.DIVN_WID

AND COALESCE(C2.EVTLOC_WID,'')=COALESCE(B.EVTLOC_WID,'')

--AND C2.MONTH_WID=B.MONTH_WID

AND C2.MONTH_WID=B.MONTH_WID

AND COALESCE(C2.MM_WID,'')=COALESCE(B.MM_WID,'')

AND B.RN1 = C2.LVL + 1 

)

SEL DEALER_WID,DIVN_WID, EVTLOC_WID,MONTH_WID,LM_WID,LLM_WID,MM_WID, EVENT_NAME,C0_QTY

FROM RSLT

QUALIFY RANK() OVER (PARTITION BY DEALER_WID,DIVN_WID, EVTLOC_WID,MONTH_WID,MM_WID  ORDER BY LVL DESC ) = 1

 

We should thank to our CS guys (RAJAT MALHOTRA)

 
 


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>