Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Can someone help with this query
Hello Oracle experts,
Well I need help changing the following query that I have constructed. I am really new at Oracle but trying my best.
I need to create a report using crystal reports where at the top I show summary data and that encompasses all data up until current date(sysdate). Then at the bottom I need to show a graph for the last 12 Months. Based on my syntax, my graph includes blank dates. My syntax will clarify what I mean. I need to graph only 12 months but at the same time show everything up above. This is not doable in crystal reports unless I include a sub report but I don't want to do this. I hate using subs especially with stored procedures. Is it doable, almost like having 2 separate queries into 1. I have used simple case statements.
So here goes
SELECT case_id_,
(CASE when convert_utc_date(Arrival_time,'EST') between trunc(sysdate -
7*2, 'DAY') and trunc(sysdate,'DAY')-(1/24/60/60) then 1 else 0
END) AS New,
(CASE when Status NOT IN (4,5) and convert_utc_date(Arrival_time,'EST')
between trunc(sysdate - 7*2, 'DAY') and
trunc(sysdate,'DAY')-(1/24/60/60) then 1 else 0
END) AS TotalOpen,
(CASE when convert_utc_date(Arrival_time,'EST') between
add_months(trunc(sysdate,'MM'),-11) and
trunc(sysdate,'DAY')-(1/24/60/60) then 1 else 0
End)AS Last12Months,
(CASE when Status NOT IN (4,5) and
convert_utc_date(Arrival_time,'EST') between
add_months(trunc(sysdate,'MM'),-11) and
trunc(sysdate,'DAY')-(1/24/60/60) then
convert_utc_date(Arrival_time,'EST')
End)Last12MonthsRecordSelection
FROM hpd_helpdesk
Result Set will look like this
Ticket17777 0 0 1 (null) Ticket15555 0 0 1 13-MAR-06 Ticket19648 0 0 1 (null)
I don't want to exclude the blanks overall, but exlucde them from being shown only in the graph. Your help is appreciated. Received on Thu Jun 29 2006 - 10:50:16 CDT