SELECT [A].[CASHFLOW_ITEM_CODE],[A].[CASHFLOW_ITEM_NAME],[A].[CASHFLOW_ITEM_PROPERTY],[D].[CASHFLOW_INITIAL_ID],[D].[MJKM],[D].[SJKMA_ID],[A].[CASHFLOW_ITEM_LEVEL],[D].[CASHFLOW_INITIAL_D_ID],[A].[CASHFLOW_ITEM_ID],[D].[P01_CASHFLOW_AMT],[D].[P02_CASHFLOW_AMT],[D].[P03_CASHFLOW_AMT],[D].[P04_CASHFLOW_AMT],[D].[P05_CASHFLOW_AMT],[D].[P06_CASHFLOW_AMT],[D].[P07_CASHFLOW_AMT],[D].[P08_CASHFLOW_AMT],[D].[P09_CASHFLOW_AMT],[D].[P10_CASHFLOW_AMT],[D].[P11_CASHFLOW_AMT],[D].[P12_CASHFLOW_AMT],[D].[P13_CASHFLOW_AMT],[D].[P14_CASHFLOW_AMT],[D].[P15_CASHFLOW_AMT],[D].[P16_CASHFLOW_AMT],[D].[P17_CASHFLOW_AMT],[D].[P18_CASHFLOW_AMT],[D].[P19_CASHFLOW_AMT],[D].[P20_CASHFLOW_AMT],[D].[P21_CASHFLOW_AMT],[D].[P22_CASHFLOW_AMT],[D].[P23_CASHFLOW_AMT],[D].[P24_CASHFLOW_AMT],[D].[P25_CASHFLOW_AMT],[D].[P26_CASHFLOW_AMT],[D].[P27_CASHFLOW_AMT],[D].[P28_CASHFLOW_AMT],[D].[P29_CASHFLOW_AMT],[D].[P30_CASHFLOW_AMT],[D].[P31_CASHFLOW_AMT],[D].[P32_CASHFLOW_AMT],[D].[P33_CASHFLOW_AMT],[D].[P34_CASHFLOW_AMT],[D].[P35_CASHFLOW_AMT],[D].[P36_CASHFLOW_AMT] FROM (SELECT ISNULL([SUBB].[CASHFLOW_INITIAL_ID],' ') AS [CASHFLOW_INITIAL_ID], [A].[MJKM] AS [MJKM], [A].[SJKMA_ID] AS [SJKMA_ID],' ' AS [CASHFLOW_INITIAL_D_ID], [A].[CASHFLOW_ITEM_ID] AS [CASHFLOW_ITEM_ID],SUM(ISNULL([SUBB].[P01_CASHFLOW_AMT],0)) AS [P01_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P02_CASHFLOW_AMT],0)) AS [P02_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P03_CASHFLOW_AMT],0)) AS [P03_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P04_CASHFLOW_AMT],0)) AS [P04_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P05_CASHFLOW_AMT],0)) AS [P05_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P06_CASHFLOW_AMT],0)) AS [P06_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P07_CASHFLOW_AMT],0)) AS [P07_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P08_CASHFLOW_AMT],0)) AS [P08_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P09_CASHFLOW_AMT],0)) AS [P09_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P10_CASHFLOW_AMT],0)) AS [P10_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P11_CASHFLOW_AMT],0)) AS [P11_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P12_CASHFLOW_AMT],0)) AS [P12_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P13_CASHFLOW_AMT],0)) AS [P13_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P14_CASHFLOW_AMT],0)) AS [P14_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P15_CASHFLOW_AMT],0)) AS [P15_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P16_CASHFLOW_AMT],0)) AS [P16_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P17_CASHFLOW_AMT],0)) AS [P17_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P18_CASHFLOW_AMT],0)) AS [P18_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P19_CASHFLOW_AMT],0)) AS [P19_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P20_CASHFLOW_AMT],0)) AS [P20_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P21_CASHFLOW_AMT],0)) AS [P21_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P22_CASHFLOW_AMT],0)) AS [P22_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P23_CASHFLOW_AMT],0)) AS [P23_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P24_CASHFLOW_AMT],0)) AS [P24_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P25_CASHFLOW_AMT],0)) AS [P25_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P26_CASHFLOW_AMT],0)) AS [P26_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P27_CASHFLOW_AMT],0)) AS [P27_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P28_CASHFLOW_AMT],0)) AS [P28_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P29_CASHFLOW_AMT],0)) AS [P29_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P30_CASHFLOW_AMT],0)) AS [P30_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P31_CASHFLOW_AMT],0)) AS [P31_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P32_CASHFLOW_AMT],0)) AS [P32_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P33_CASHFLOW_AMT],0)) AS [P33_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P34_CASHFLOW_AMT],0)) AS [P34_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P35_CASHFLOW_AMT],0)) AS [P35_CASHFLOW_AMT],SUM(ISNULL([SUBB].[P36_CASHFLOW_AMT],0)) AS [P36_CASHFLOW_AMT] FROM (SELECT ISNULL([SUBA].[MOJI],0) AS [MJKM],ISNULL([SJKMA].[SJKM_ID],[A].[CASHFLOW_ITEM_ID]) AS [SJKMA_ID], [A].[CASHFLOW_ITEM_ID] AS [CASHFLOW_ITEM_ID] FROM [CASHFLOW_ITEM] AS [A] LEFT OUTER JOIN (SELECT [A].[CASHFLOW_ITEM_ID] AS [CASHFLOW_ITEM_ID],COUNT([B].[CASHFLOW_ITEM_ID]) AS [MOJI] FROM [CASHFLOW_ITEM] AS [A] INNER JOIN [CASHFLOW_ITEM] AS [B] ON (([B].[CASHFLOW_ITEM_CODE] LIKE ([A].[CASHFLOW_ITEM_CODE]+'%') ) AND ([B].[CASHFLOW_ITEM_LEVEL] > [A].[CASHFLOW_ITEM_LEVEL])) WHERE (((([A].[CASHFLOW_DATASET_ID] = '11603881c248884364fa6b146fa7ba1e16a85') AND (([A].[SOURCE_ID_ROid] = '*') OR ([A].[SOURCE_ID_ROid] = '10209179bbe7cacf04a6b84b01ed777d6590d'))) AND ([A].[ApproveStatus] = 'Y'))) GROUP BY [A].[CASHFLOW_ITEM_ID]) AS [SUBA] ON ([A].[CASHFLOW_ITEM_ID] = [SUBA].[CASHFLOW_ITEM_ID]) LEFT OUTER JOIN (SELECT [B].[CASHFLOW_ITEM_ID] AS [CASHFLOW_ITEM_ID], [A].[CASHFLOW_ITEM_ID] AS [SJKM_ID] FROM [CASHFLOW_ITEM] AS [A] INNER JOIN [CASHFLOW_ITEM] AS [B] ON (([B].[CASHFLOW_ITEM_CODE] LIKE ([A].[CASHFLOW_ITEM_CODE]+'%') ) AND (([B].[CASHFLOW_ITEM_LEVEL]-[A].[CASHFLOW_ITEM_LEVEL]) = 1)) WHERE (((([A].[CASHFLOW_DATASET_ID] = '11603881c248884364fa6b146fa7ba1e16a85') AND (([A].[SOURCE_ID_ROid] = '*') OR ([A].[SOURCE_ID_ROid] = '10209179bbe7cacf04a6b84b01ed777d6590d'))) AND ([A].[ApproveStatus] = 'Y')))) AS [SJKMA] ON ([A].[CASHFLOW_ITEM_ID] = [SJKMA].[CASHFLOW_ITEM_ID]) WHERE ((((([A].[CASHFLOW_DATASET_ID] = '11603881c248884364fa6b146fa7ba1e16a85') AND (([A].[SOURCE_ID_ROid] = '*') OR ([A].[SOURCE_ID_ROid] = '10209179bbe7cacf04a6b84b01ed777d6590d'))) AND ([A].[ApproveStatus] = 'Y')) AND (ISNULL([SUBA].[MOJI],0) > 0)))) AS [A] LEFT OUTER JOIN (SELECT [A].[CASHFLOW_ITEM_ID] AS [CASHFLOW_ITEM_ID], [B].[CASHFLOW_ITEM_ID] AS [SUB_CASHFLOW_ITEM_ID] FROM [CASHFLOW_ITEM] AS [A] INNER JOIN [CASHFLOW_ITEM] AS [B] ON (([B].[CASHFLOW_ITEM_CODE] LIKE ([A].[CASHFLOW_ITEM_CODE]+'%') ) AND ([B].[CASHFLOW_ITEM_LEVEL] > [A].[CASHFLOW_ITEM_LEVEL])) WHERE (((([A].[CASHFLOW_DATASET_ID] = '11603881c248884364fa6b146fa7ba1e16a85') AND (([A].[SOURCE_ID_ROid] = '*') OR ([A].[SOURCE_ID_ROid] = '10209179bbe7cacf04a6b84b01ed777d6590d'))) AND ([A].[ApproveStatus] = 'Y')))) AS [ZQZ] ON ([A].[CASHFLOW_ITEM_ID] = [ZQZ].[CASHFLOW_ITEM_ID]) LEFT OUTER JOIN (SELECT [D1].[CASHFLOW_INITIAL_ID] AS [CASHFLOW_INITIAL_ID], [A].[MJKM] AS [MJKM], [A].[SJKMA_ID] AS [SJKMA_ID], [D1].[CASHFLOW_INITIAL_D_ID] AS [CASHFLOW_INITIAL_D_ID], [A].[CASHFLOW_ITEM_ID] AS [CASHFLOW_ITEM_ID],ISNULL([D1].[P01_CASHFLOW_AMT],0) AS [P01_CASHFLOW_AMT],ISNULL([D1].[P02_CASHFLOW_AMT],0) AS [P02_CASHFLOW_AMT],ISNULL([D1].[P03_CASHFLOW_AMT],0) AS [P03_CASHFLOW_AMT],ISNULL([D1].[P04_CASHFLOW_AMT],0) AS [P04_CASHFLOW_AMT],ISNULL([D1].[P05_CASHFLOW_AMT],0) AS [P05_CASHFLOW_AMT],ISNULL([D1].[P06_CASHFLOW_AMT],0) AS [P06_CASHFLOW_AMT],ISNULL([D1].[P07_CASHFLOW_AMT],0) AS [P07_CASHFLOW_AMT],ISNULL([D1].[P08_CASHFLOW_AMT],0) AS [P08_CASHFLOW_AMT],ISNULL([D1].[P09_CASHFLOW_AMT],0) AS [P09_CASHFLOW_AMT],ISNULL([D1].[P10_CASHFLOW_AMT],0) AS [P10_CASHFLOW_AMT],ISNULL([D1].[P11_CASHFLOW_AMT],0) AS [P11_CASHFLOW_AMT],ISNULL([D1].[P12_CASHFLOW_AMT],0) AS [P12_CASHFLOW_AMT],ISNULL([D1].[P13_CASHFLOW_AMT],0) AS [P13_CASHFLOW_AMT],ISNULL([D1].[P14_CASHFLOW_AMT],0) AS [P14_CASHFLOW_AMT],ISNULL([D1].[P15_CASHFLOW_AMT],0) AS [P15_CASHFLOW_AMT],ISNULL([D1].[P16_CASHFLOW_AMT],0) AS [P16_CASHFLOW_AMT],ISNULL([D1].[P17_CASHFLOW_AMT],0) AS [P17_CASHFLOW_AMT],ISNULL([D1].[P18_CASHFLOW_AMT],0) AS [P18_CASHFLOW_AMT],ISNULL([D1].[P19_CASHFLOW_AMT],0) AS [P19_CASHFLOW_AMT],ISNULL([D1].[P20_CASHFLOW_AMT],0) AS [P20_CASHFLOW_AMT],ISNULL([D1].[P21_CASHFLOW_AMT],0) AS [P21_CASHFLOW_AMT],ISNULL([D1].[P22_CASHFLOW_AMT],0) AS [P22_CASHFLOW_AMT],ISNULL([D1].[P23_CASHFLOW_AMT],0) AS [P23_CASHFLOW_AMT],ISNULL([D1].[P24_CASHFLOW_AMT],0) AS [P24_CASHFLOW_AMT],ISNULL([D1].[P25_CASHFLOW_AMT],0) AS [P25_CASHFLOW_AMT],ISNULL([D1].[P26_CASHFLOW_AMT],0) AS [P26_CASHFLOW_AMT],ISNULL([D1].[P27_CASHFLOW_AMT],0) AS [P27_CASHFLOW_AMT],ISNULL([D1].[P28_CASHFLOW_AMT],0) AS [P28_CASHFLOW_AMT],ISNULL([D1].[P29_CASHFLOW_AMT],0) AS [P29_CASHFLOW_AMT],ISNULL([D1].[P30_CASHFLOW_AMT],0) AS [P30_CASHFLOW_AMT],ISNULL([D1].[P31_CASHFLOW_AMT],0) AS [P31_CASHFLOW_AMT],ISNULL([D1].[P32_CASHFLOW_AMT],0) AS [P32_CASHFLOW_AMT],ISNULL([D1].[P33_CASHFLOW_AMT],0) AS [P33_CASHFLOW_AMT],ISNULL([D1].[P34_CASHFLOW_AMT],0) AS [P34_CASHFLOW_AMT],ISNULL([D1].[P35_CASHFLOW_AMT],0) AS [P35_CASHFLOW_AMT],ISNULL([D1].[P36_CASHFLOW_AMT],0) AS [P36_CASH