What I can't figure out (newbie) is how to also include records on top of the above query where FY_CD < 2017 Rate Type = A, and FY CD = 2017 Rate Type = T and FY CD = 2018 Rate Type = T.
SELECT PROJ_ID, ACCT_ID, FY_CD, PD_NO, POOL_NO, POOL_NAME, RATE_TYPE, PTD_INCUR_AMT, CASE WHEN RATE_TYPE = 'T' OR RATE_TYPE = 'A' THEN '5. INDIRECT' ELSE (CASE WHEN ACCT_ID LIKE '%-60-100' THEN '2. TEMP LABOR' WHEN ACCT_ID LIKE '%-60-150' THEN '2. TEMP LABOR' WHEN ACCT_ID LIKE '%-10-%' THEN '1. LABOR' WHEN ACCT_ID LIKE '%-40-%' THEN '3. MATERIAL' ELSE '4. ODC' END) END AS CostGroup, LEFT(PROJ_ID, 10) AS ShortName, SUB_TOT_TYPE_NO AS SubTotTypeNo, CASE WHEN FY_CD = 2018 AND RATE_TYPE = 'T' THEN PTD_INCUR_AMT WHEN FY_CD < 2018 AND RATE_TYPE = 'A' THEN PTD_INCUR_AMT WHEN RATE_TYPE = 'N' THEN PTD_INCUR_AMT END AS TotalAmt, YEAR(GETDATE()) AS CurrentFY FROM DELTEKCP.DELTEK.PSR_FINAL_DATA WHERE (SUB_TOT_TYPE_NO <> 1)
From novice to tech pro — start learning today.