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!

Avoid exists and not exists independent clauses

raj2k8mcaFeb 19 2020 — edited Feb 20 2020

Hi experts ,

         Please suggest me how to avoid using exists and not exists operator in the below query?

SELECT DISTINCT  AM_MST_RECORD_ID    as "ACTIVITY",

                 REPLACE(UAR_FUNCTION,'List','Master')      aS  "MODULE",

                 'REVERTED'  as "STATUS",

                 TRUNC(AM_CR_DT) AS "CreateDate",

                 ROUND(SYSDATE - NVL(AM_REV_DT,SYSDATE)) AS "Aging",

                 SYSDATE - NVL(AM_REV_DT,SYSDATE) AS "Aging_sort",

                 AM_PGNAME_ID  AS "PageID",

                 PAGE_URL as "URL",

                 AM_MST_CODE AS "Code"

           FROM  PM_APPROVER_MASTER A

           LEFT OUTER JOIN LD_USER_RIGHTS B

          ON     B.UAR_MENU_ID     = A.AM_PGNAME_ID

          WHERE  AM_CR_BY= In_UserId

          AND    AM_STATUS = 'E'

          AND    AM_FRZ_FLAG ='N'

          AND    AM_REV_DT IS NOT NULL

          AND FN_DASHBOARD_REVERT_STATUS(AM_PGNAME_ID,AM_MST_RECORD_ID,AM_STATUS) =1

          and    NOT EXISTS (SELECT 1 FROM PM_APPROVER_MASTER WHERE AM_MST_RECORD_ID=A.AM_MST_RECORD_ID--ADDED BY MAHADEV ON 10TH MAY

          AND    AM_CR_BY=A.AM_CR_BY AND AM_FRZ_FLAG='Y');

Comments
Post Details
Added on Feb 19 2020
4 comments
489 views