I have a table which millions of records like this:
The desired format of the data is this:
how do i achieve this? tried a cross join but didnt help. pivot is taking too long to execute as the dataset is huge.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
I think you don't need any cross join.
in SQL, you can write statement like this
select JD_WS_CD || '_' || JD_WS_SUB_CD || '_' || JD_SHP_TO, case when YM='202301' then AMT1 end as JAN_AMT1, case when YM='202302' then AMT1 end as FEB_AMT1, case when YM='202303' then AMT1 end as MAR_AMT1 FROM table ...
First Column =A2 & "_" & B2& "_" & C2 JAN_AMT1 Column =IF(D2=202301;E2;"") FEB_AMT1 Column =IF(D2=202302;E2;"") MAR_AMT1 Column =IF(D2=202303;E2;"")