Sep 14 2024 04:33 PM
Hello ,
I need help with examining this query.
I have this query below and my requirements. The First Requirement is
1. If appselection !='notice to process' and notetxt is NULL in last month show acct and no txt notes
2. if appselection='notice to process' and no notetxt in one month show the results (acctid)
---------------------------------------------------------------------------------------
WITH NOTATION AS (SELECT
acctid,
appselection,
notetxt,xtp,
ndate
FROM TABLEA),
City as (acctid,
appselection
FROM EXAMPLE)
SELECT a.acctid,b.appselection,a.notetxt,a.ndate,a.xtp
FROM NOTATION a
LEFT JOIN b
ON a.acctid=b.acctid
WHERE b.appselection='notice to process' AND (a.notetxt IS NULL OR TO_DATE(a.ndate, 'mm/dd/yyyy')<=ADD_Months(SYSDATE,-1))) OR b.appselection='notice to process' AND (a.notetxt IS NULL OR TO_DATE(a.ndate,'mm/dd/yyyy')<=ADD_MONTHS(sysdaate,-1)))
-------------------------------------------------------------------------------------
I need another Where clause for requirement 2 using the same query above
REQUIREMENT b: show acctid with no notetxt in Last 2 weeks. below is what I have
WHERE n.notetxt IS NULL AND TO_DATE(n.ndate, 'mm/dd/yyyy')<=CURREN_DATE-14)
Sep 14 2024 11:23 PM
Sep 15 2024 08:06 AM
The Two conditions are to produce one result set.
The resulting table should be like this;
ACCTID NDATE NOTETXT APPSTATUS
000001 02/06/2023 FIRE INCIDENT NO NOTICE
000002 03/09/2024 MINOR FIRE NOTICE TO PROCESS
000003 09/09/2024 NO INCIDENT NOTICE TO PROCESS
000004 03/07/2024 NO NOTICE
Sep 15 2024 08:36 AM
Sep 15 2024 12:53 PM
Sep 15 2024 04:16 PM
Sep 15 2024 08:23 PM