Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Read only access - Using search criteria outside of the WHERE clause.

2661188May 6 2014 — edited May 6 2014

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

SYSDATEASSIGNED TOTicket CountHigh/CriticalMedium/LowOpenOffenders
06-MAY-14Name16000445953 446320 449175 450135 451773 451950
06-MAY-14Name27000438290 447993 448738 451948 452052 452133 452298
06-MAY-14Name310040416095 421399 423451 437093 437123 443578 446656 447796 451288 452412
06-MAY-14Name421000447978 448187 449248 449363 449442 449492 449494 449729 450341 450433 450434 450491 450973 450987 451199 451705 451927 451940 451944 451947 452257
06-MAY-14Name511020434772 446063 448786 448980 449821 450131 450389 450684 450737 451412 452268
06-MAY-14Name610000410078 428098 436618 444606 450711 451010 451229 451845 451980 452189
06-MAY-14Name77000450318 450442 450977 451697 451710 451841 452378
06-MAY-14Name811000

439143 444393 445144 446168 447094 447413 448493 449988 450855 451001 451693

06-MAY-14Name95100441038 445758 447871 450493 451567
06-MAY-14Name102000

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.

This post has been answered by Solomon Yakobson on May 6 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2014
Added on May 6 2014
3 comments
129 views