What I'm trying to do is filter through the stragg output so that it only displays the "Offenders" or the tickets that are out of date as shown by the lines above it, but I also need to have 2 columns that do not search through these specific dates. They only need to have the one condition specified in the WHERE clause.
I don't know if there is a way to do this, or if I need to use a completely different method. Any help would be appreciated. In the results, the Offenders column shows all NOT Completed tickets grouped by the person who logged the ticket, but I only want it to show the tickets that are being counted in the High/Critical, Medium/Low, and Open columns.
I'm aware of the old syntax for the joins.. Pay no attention to that unless it absolutely is an issue.
SELECT SYSDATE
,au_a.user_nm AS "ASSIGNED TO"
,COUNT(DISTINCT t.tkt_sid) AS "Ticket Count"
,COUNT(DISTINCT(CASE WHEN
((t.rcd_lst_user_ts < TRUNC(SYSDATE - 1) AND ts.tkt_sts_dsc = 'In Progress' AND tp.prty_dsc = 'Critical')
OR (t.rcd_lst_user_ts < TRUNC(SYSDATE - 4) AND ts.tkt_sts_dsc = 'In Progress' AND tp.prty_dsc = 'High')
OR (t.rcd_lst_user_ts < TRUNC(SYSDATE - 8) AND ts.tkt_sts_dsc = 'Pending' AND tp.prty_dsc = 'High')
OR (t.rcd_lst_user_ts < TRUNC(SYSDATE - 1) AND ts.tkt_sts_dsc = 'Open' AND tp.prty_dsc = 'High'))
THEN t.tkt_sid else null end)) AS "High/Critical"
,COUNT(DISTINCT(CASE WHEN
((t.rcd_lst_user_ts < TRUNC(SYSDATE - 16) AND ts.tkt_sts_dsc = 'In Progress' AND tp.prty_dsc = 'Medium')
OR (t.rcd_lst_user_ts < TRUNC(SYSDATE - 29) AND ts.tkt_sts_dsc = 'In Progress' AND tp.prty_dsc = 'Low')
OR (t.rcd_lst_user_ts < TRUNC(SYSDATE - 22) AND ts.tkt_sts_dsc = 'Pending' AND tp.prty_dsc = 'Medium')
OR (t.rcd_lst_user_ts < TRUNC(SYSDATE - 43) AND ts.tkt_sts_dsc = 'Pending' AND tp.prty_dsc = 'Low'))
THEN t.tkt_sid else null end)) AS "Medium/Low"
,COUNT (DISTINCT(case when (ts.tkt_sts_dsc = 'Open') then 1 else null end)) AS "Open"
,sys.Stragg(DISTINCT t.tkt_sid || ' ') AS "Offenders"
FROM afp_asd.tkt t
,afp_asd.tkt_prty tp
,afp_asd.tkt_sts ts
,afp_asd.tkt_log tl
,afp_asd.agt a
,afp_asd.asd_user au_a
WHERE TKT_STS_DSC NOT LIKE 'Completed'
AND t.prty_cd = tp.prty_cd
AND t.tkt_sts_cd = ts.tkt_sts_cd
AND t.agt_sid = a.agt_sid
AND t.assigned_id = au_a.asd_user_id
AND t.tkt_sid = tl.tkt_sid
AND tl.rcd_lst_user_ts >= :b_start_date
GROUP BY au_a.user_nm
| SYSDATE | ASSIGNED TO | Ticket Count | High/Critical | Medium/Low | Open | Offenders |
|---|
| 06-MAY-14 | Name1 | 6 | 0 | 0 | 0 | 445953 446320 449175 450135 451773 451950 |
| 06-MAY-14 | Name2 | 7 | 0 | 0 | 0 | 438290 447993 448738 451948 452052 452133 452298 |
| 06-MAY-14 | Name3 | 10 | 0 | 4 | 0 | 416095 421399 423451 437093 437123 443578 446656 447796 451288 452412 |
| 06-MAY-14 | Name4 | 21 | 0 | 0 | 0 | 447978 448187 449248 449363 449442 449492 449494 449729 450341 450433 450434 450491 450973 450987 451199 451705 451927 451940 451944 451947 452257 |
| 06-MAY-14 | Name5 | 11 | 0 | 2 | 0 | 434772 446063 448786 448980 449821 450131 450389 450684 450737 451412 452268 |
| 06-MAY-14 | Name6 | 10 | 0 | 0 | 0 | 410078 428098 436618 444606 450711 451010 451229 451845 451980 452189 |
| 06-MAY-14 | Name7 | 7 | 0 | 0 | 0 | 450318 450442 450977 451697 451710 451841 452378 |
| 06-MAY-14 | Name8 | 11 | 0 | 0 | 0 | 439143 444393 445144 446168 447094 447413 448493 449988 450855 451001 451693 |
| 06-MAY-14 | Name9 | 5 | 1 | 0 | 0 | 441038 445758 447871 450493 451567 |
| 06-MAY-14 | Name10 | 2 | 0 | 0 | 0 | |
So for Name3 it should only show 4 ticket numbers. If someone has all zeros, such as Name10.. It should just be blank or say NULL.