I need to modify the following query to limit the data by quarters. 1 row of data for the previous & 1 row per current quarters. I currently am using a Union query (this is only 1 part of the Union qry) to create the unique rows of data, but I need help limiting the data by previous & current quarters.
I have tried using ranking and using the sysdate to create the quarter, however how do I limit the date I am using (gpa_prd_enddt) in the WHERE clause to display a row of data for each quarter requied?
Select DISTINCT A.SUPPLIER_ID
, ( SELECT to_char(sysdate,'YYYY-"Q"Q') FROM dual) as CurQtr
-- , ( SELECT to_char(add_months(trunc(sysdate,'mm'),-3),'YYYY-"Q"Q') FROM dual)as PrevQtr
, to_char(A.gpa_prd_enddt,'YYYY-"Q"Q') ENDDATE
, Null GPA_Cost
, Null GPA_Mgmt
, Null GPA_Qual
, Null GPA_Sch
, Null Cost_CMT
, Null Mgmt_CMT
, Null Qual_CMT
, Null Sch_CMT
, Eval_CMT Tech_CMT
FROM GPA_DIM A
INNER JOIN gpa_evaluation B ON A.GPA_ID = B.GPA_ID
INNER JOIN PERFORMANCE_BUS_GRP C ON A.ESDW_SUPPLIER_ID = C.ESDW_SUPPLIER_ID
WHERE Evaluation_Cat = 'T'
-- AND to_char(A.gpa_prd_enddt,'YYYY-"Q"Q') = (SELECT to_char(sysdate,'YYYY-"Q"Q') FROM dual)