dynamic sql from the below sql code

0

Could you please help me create a dynamic sql from the below sql code.

select * from

(SELECT U.ODF_PARENT_ID PROJECT_ID, U.ID UNIT_ID, COUNTRY_OBS.OBS_UNIT_ID, SUM(NVL(SLICE,0)) SLICE , TO_CHAR(SLICE_DATE,'MON YY') Month_label

FROM ODF_SL_5019059,  ODF_CA_PPD_UNIT_FORECAST UF ,ODF_CA_PPD_UNIT U, NBI_DIM_OBS COUNTRY_OBS

WHERE SLICE_REQUEST_ID=5005021

AND PRJ_OBJECT_ID = UF.ID

AND UF.ODF_PARENT_ID=U.ID

AND U.ODF_PARENT_ID = 5131001

AND  UF.PPD_COUNTRY=COUNTRY_OBS.OBS_UNIT_ID

--AND TRUNC(SLICE_DATE,'MONTH') >= TRUNC(SYSDATE,'MONTH')

AND TRUNC(SLICE_DATE,'YEAR') = TRUNC(SYSDATE,'YEAR')

GROUP BY U.ODF_PARENT_ID, U.ID, COUNTRY_OBS.OBS_UNIT_ID , TO_CHAR(SLICE_DATE,'MON YY') ) main

pivot

(sum(SLICE) for MONTH_LABEL IN ('Jan 00' , 'Feb 00', 'Apr 18'))

I am not able to convert it.

Please guide me.

Thanks.

Link: dynamic sql from the below sql code
Source: Stack Sql

Share.

About Author

Leave A Reply