I have a case statement displaying all 4 quarters. I also want to display current year as cy, but the case statement is ignoring the current year
select
case when trunc(date_gra_created) between q1_begin_date and q1_end_date then 'Q1'
when trunc(date_gra_created) between q2_begin_date and q2_end_date then 'Q2'
when trunc(date_gra_created) between q3_begin_date and q3_end_date then 'Q3'
when trunc(date_gra_created) between q4_begin_date and q4_end_date then 'Q4'
when trunc(date_gra_created) between q1_begin_date and report_end_date then 'ytd'
end dates
from rpt_quarter qr
ouptut
Q1
Q2
Q3
Q4
Whereas, I want the output to be
Q1
Q2
Q3
Q4
YTD
I know the reason is because YTD is overlapping with Q1 to Q4 and since it's the last item, case statement doesn't choose it.
What could I do to show YTD. I tried union all, but that's taking a long time for my report to run. Is there any other method that I could apply. Thanks in advance!