Thursday, 15 January 2015

sql - Query Refactor without union -


The

What might we can factor down the query without using the union that we can use where condition Or logical operator

  One as one. Request number, Akticket_id, Tiketaidi, a.requester, num_business_days (a.last_modified_date, sysdate) choose as business, REM_MAIL_SENT_DTTS (SELECT Tikt_aidi, request number as the number, designed as a requestor, Antim_modifaid_det, Araim_aims_ti Ktititis, Ri_Ticket_Info where Sthiti_aidi = 6 and REM_MAIL_SENT_DTTS tap) a where num_business_days (a.last_modified_date, sysdate) & gt; = 5 Union Select one. Request number, one. Ticket_id as ticketID, a.requester, num_business_days (a.last_modified_date, sysdate) as Businessdays, the a.REM_MAIL_SENT_DTTS (SELECT Tikt_aidi, no request as a request number, designed as the requestor, the Antim_snchalit_det, Araim_aims_diitititio, Ri_Ticket_Info where Sthiti_aidi = 6 and REM_MAIL_SENT_DTTS not null) where num_business_days (a.REM_MAIL_SENT_DTTS, sysdate) & gt; = 5  

I think it can be rewritten as simply :

  SELECT a.requestnumber, ticket as a.ticket_id, a. The requestor, num_business_days (a.last_modified_date, SYSDATE) AS businessman, a.rem_mail_sent_dtts FROM ri_ticket_info a WHERE a.status_id = 6 and num_business_days (nvl (a.rem_mail_sent_dtts, a.last_modified_date, SYSDATE) & gt; = 5;  

No comments:

Post a Comment