To only convert NOT EXISTS query JOIN plain

Version: 10.2.0.5

Developers have complained that the following query works very poorly and hooked most of the time.

select distinct cust_id from cust_track_dtl TD
     where not exists 
     (select 1 from cust_master CM where TD.cust_id = CM.cust_id 
     and CM.rgn_code = TD.rgn_code
     CM.rgn_code = 'AP'
      )
and TD.stat_code = 'C'
and TD.proc_flag = 'Y'
TD.rgn_code = 'AP'  ; ----------------> Is this logically correct ?
CUST_TRACK_DTL table in the outer query has 2 million records

CUST_MASTER table in their inner query(sub query) has 30 million records
Currently, we are only at the design phase. I'm a bit confused about the
rgn_code = 'AP'
appearing in internal and external queries.

I think that the motion seeks to recover all customers who are not the "AP" region, but the outer query WHERE clause has
TD.rgn_code = 'AP'
Is there something wrong with this logic?

If it is logically correct, how can I convert this request with simple JOIN (ie. How can I get rid of NO thing EXISTS)?

Your original. Rgn_code = "AP" is not necessary in the subquery but will change the results of the outer query.

select distinct cust_id from cust_track_dtl TD
  left outer join cust_master CM
    on (TD.cust_id = CM.cust_iid AND
        CM.rgn_code = TD.rgn_code)
 WHERE TD.stat_code = 'C'
   and TD.proc_flag = 'Y'
   and TD.rgn_code = 'AP'
   and CM.cust_id IS NULL;

or the other

select pb.pub_name from publishers pb
  LEFT OUTER JOIN titles tt ON
    ON (tt.pubslisher_id = pb.publisher_id and
        tt.subject = 'RELIGION')
 where tt.pubslisher_id IS NULL;

Tags: Database

Similar Questions

  • How to use the not exists query

    Hello

    Using obiee 11g,.
    I would like to know how treat does not exist the application in the obiee11g,

    the query is like that

    Select count (a.col1), a.col2 from table1, table2 b where a.col1 = b.col1
    and not exists
    (by selecting d.col1 in table 3, table 4 e)
    where d.col1 = e.col1 and d.col1 = a.col1)
    A.col2 Group

    There are 4 tables.
    Table1, table2, table 3, tabel4

    That's what I need in a report, these tables are used in other places also.
    prefer if possible to do an analysis of i.e.e report itself.
    If this isn't possible then can be in Dr. because if I change in RPD it can reflect all the places
    and not in a report itself.

    Thank you

    This implementation in the report itself can be a difficult and tedious work... But it is better to be RPD - physical type - select a Table
    USE NOT IN in place of NOT exist... You can just use a SELECT statement to SELECT the TYPE of TABLE

    I hope that's clear

  • Unable to join the domain "DNS name does not exist."

    Working on this computer remotely in my company, it has more a problem but at this moment, that we focus on trying to reach the area. We removed everything first to see if it would fix the trust relationship issues she felt the long side not being able to browse the files all computer network or servers.
    When trying to join the field, that's what we get in the dcdiag.txt in the debug folder.
    The domain name 'xxxxx' can be a NetBIOS domain name.  If this is the case, check that the domain name is properly registered with WINS.
    If you are certain that the name is not a NetBIOS domain name, then the following information can help you troubleshoot your DNS configuration.
    The following error occurred when DNS was questioned about the resource record (SRV) service location used to locate an Active Directory (AD DC) domain controller for the domain "xxxxx":
    The error was: "the DNS name does not exist."
    (0x0000232B RCODE_NAME_ERROR error code)
    The query was for the SRV record for _ldap._tcp.dc._msdcs.xxxxx
    Common causes of this error are:
    -The DNS SRV records to locate an AD DC for the domain are not registered in DNS. These records are automatically saved with a DNS server when an AD domain controller is added to a domain. They are updated by the AD DC at set intervals. This computer is configured to use DNS servers with the following IP addresses:
    198.6.1.5
    198.6.100.38
    -One or more of the following areas do not include delegation to its child zone:
    XXXXX
    . (the root zone)
    XXXXX = domain
    Also the listed IP addresses have been changed.

    I worked on this computer for about 2 days, and then the user is able to work remotely with a server terminal server, they will need access to the server later.

    Reset the network device - completely.  Uninstall the network driver and have someone there install the latest manufacturer.

    Manually enter the DNS information for the DNS servers of your company on the computer - even if it uses DHCP.

    Make sure that its time/time zone is the same as your DNS server.

    Reset all default HOSTS file.

    Ping the DNS server.

    When you join - use the FQDN (mycompany.local, etc..)

  • That IS NULL is done by replacing the NOT EXISTS operator with an outer join?

    DB version: 10 gr 2

    An example of searchoracle.target.com

    The query that contains a NOT EXISTS operator
    SELECT M.ModulId, M.Modul FROM MODULE M
    WHERE NOT EXISTS
    ( SELECT PROJEKTMODUL.IdModul 
      FROM PROJEKTMODUL 
      WHERE M.ModulId = PROJEKTMODUL.IdModul 
      AND PROJEKTMODUL.IdProjekt = 23 )
    is replaced by an equivalent outer join query
    select distinct
           M.ModulId
         , M.Modul 
      from MODULE M
    left outer
      join PROJEKTMODUL
        on M.ModulId = PROJEKTMODUL.IdModul
       and PROJEKTMODUL.IdProjekt = 23
     where PROJEKTMODUL.IdProjekt is null
    I do not understand what
    PROJEKTMODUL.IdProjekt is null
    fact in the above rewritten query.

    He is to perform an anti-jointure. As far as I know Oracle (starting with version 10g - I thought that release 1) rewritten a Join Anti that resembles your second query of your request NOT EXISTS and NOT IN.

    Look at the results of the query without the predicate IS NULL and see what records (from this set) must be selected to show the same results as the first query. Areas of interest match the predicate IS NULL.

  • Select in 1 table only if a value does not exist

    Hi all
    I have problems, develop a single select statement to accomplish a single return value. I tried variations of DECODE and COALESCE, but it eludes me.

    I have two tables which are as follows:

    NAME
    ID FULLNAME
    1, senior officer
    Junior 2,
    3, Mister
    4, Senor
    5, Miss

    ABBREVIATION
    ID, ABBR.
    1, Sr
    2, jr
    3, M.
    5, ms

    What I want to do is choose from the table NAME only if that the value does not exist in the ABBREVIATION table.
    Ideally if I were to do something like:

    SELECT * FROM... WHERE (ID = 1 or ID = 2 or ID = 4)...

    I would get the following output:

    1, Sr
    2, jr
    4, Senor

    Thanks for reading!

    You want an outer join.

    SELECT decode(a.abbrev, NULL, n.fullname, a.abbrev)
    FROM name n,
    abbreviation a
    WHERE n.ID = a.ID(+)
      AND ....
    

    Something like that.

    Complete example:

    with n as (
    select 1 as ID, 'Senior' as FULLNAME from dual UNION ALL
    select 2 as ID, 'Junior' as FULLNAME from dual UNION ALL
    select 3 as ID, 'Mister' as FULLNAME from dual UNION ALL
    select 4 as ID, 'Senor' as FULLNAME from dual UNION ALL
    select 5 as ID, 'Miss' as FULLNAME from dual),
    a as (
    select 1 as ID, 'Sr' as ABBREV from dual UNION ALL
    select 2 as ID, 'Jr' as ABBREV from dual UNION ALL
    select 3 as ID, 'Mr' as ABBREV from dual UNION ALL
    select 5 as ID, 'Ms' as ABBREV from dual)
    select decode(a.abbrev, NULL, n.fullname, a.abbrev)
    from a, n
    where n.id = a.id(+)
    order by n.id;
    
    ID                     DECODE(A.ABBREV,NULL,N.FULLNAME,A.ABBREV)
    ---------------------- -----------------------------------------
    1                      Sr
    2                      Jr
    3                      Mr
    4                      Senor
    5                      Ms                                        
    
    5 rows selected
    

    Published by: tk-7381344, November 17, 2008 13:31

  • "Error running query: the real member does not exist in the application.

    Hi all

    I have a HFM EN users need to run, but somehow they started getting this error "error running query: real member does not exist in the application". I traced their levels of access to mine, and I am able to run the same report without any problem but the user still getting the same error. what may be the possible cause. Please help me so that I can ensure the debugging.

    Thank you

    Zitouni

    I was able to solve this problem by checking the user of security principals class was trying to run the report for. The user did not have acesss on the class of the said security and change all, solve the problem.

    Thanks, Sattu

  • Can I upgrade from lightroom 5 to 6 or 6 does not exist anymore, and my only option is to Lightroom CC?

    Can I upgrade from lightroom 5 to 6 or 6 does not exist anymore, and my only option is to Lightroom CC?

    Hello

    You can proceed to LR 6.

    Please see store Adobe - Adobe Lightroom 6 - upgrade

    Hope that helps!

    Kind regards

    Sheena

  • Excuse me, but I only am not able to cancel my plain... I already saw the tutorial, but where there is the choice to cancel the plain I see only a white window...

    Excuse me, but I only am not able to cancel my plain... I already saw the tutorial, but where there is the choice to cancel the plain I see only a white window...

    This is an open forum, not the Adobe support... You need Adobe support to cancel a subscription

    -Cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html

    -or http://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html

    -or by phone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • Failed: Cannot access the remote Converter Standalone Agent service. It does not exist or is not responding.

    When I try to run the converter that we receive the following error message, FAILED: cannot access the remote Converter Standalone Agent service. It does not exist or is not responding.

    RaymondT

    Given that the conversion works, you can have a software or configuration of Windows Server. Check the Windows event logs. Anything in current policies that could prevent?

  • error in the table of boat or view does not exist, but on query sql prompt works

    Hello
    Can someone help me understand the error ORA-00942: table or view does not exist when compiling the package on Oracle 9.2.0.4.0

    The below package compiled in the use of the system and trying some queries against the view v$ session_wait however getting error below.

    PACKAGE OF THE BODY SYSTEM. PK_DB_ALERT
    Online: 212
    PL/SQL: ORA-00942: table or view does not exist

    I can run the same query mentioned below sql prompt the user of the system, and it works very well however he dislikes package, please advice, thank you in advance.


    SELECT SID, seq #, event, wait_time
    V $ session_wait
    WHERE event NOT LIKE ' SQL * Net %' AND wait_time <>0
    ORDER BY 2

    DDD says:
    Hello
    Can someone help me understand the error ORA-00942: table or view does not exist when compiling the package on Oracle 9.2.0.4.0

    That means package owner is granted select view not directly, but through roles. However, the roles are ignored by stored rights define or packages stored procedures or functions/triggers... You must grant select owner directly the view package.

    SY.

    Published by: Solomon Yakobson, January 21, 2010 04:06

  • Table or view does not exist - ONLY in the procedure?

    I'm trying to write a procedure that is very simple - the only thing at this point, I'm trying to get it to do is an insert into a table - selected values from one schema to another user (on which I have select privileges to). When compiling, you receive an error ORA-942 - table or view does not exist. However, if I put the same insert statement in an anonymous PL/SQL block, it works as expected. What Miss me?

    Oracle 10.2.0.3.0 on AIX 5.3

    You are missing the explicit subsidies on the table.

    When you issue this through SQL * Plus, or through an anonymous block you use grants which are given by a role.
    Inside PL/SQL procedures, you cannot use the permissions that come with roles. Instead, the user must have appropriate subsidies being explicitly for the operations required on this object.

    GRANT SELECT / INSERT etc. on this table to the user explicitly and it will work.

  • Firefox only opens and indicates that the personal information settings do not exist or are not accessible

    Firefox does not open for me to make changes in order to correct the problem. The error box simply States that personal information settings do not exist or are inaccessible. This isn't a problem on this computeror I wouldn't be able to send this message.

    This is usually caused by a problem with the file profiles.ini and the profile marked as the default value = 1 is no longer present on the hard drive.

    • Windows: '% AppData%\Mozilla\Firefox\ '.
    • Linux: ~/.mozilla/firefox/
    • Mac: ~/Library/Application Support/Firefox /.
    • Remove the profiles.ini file to force Firefox to create a new default profile
    • Use the Profile Manager to create a new profile
    • "Select a file" allows to retrieve an existing profile, if there is always a present

    See also "create a profile":

    If the new profile works then you can transfer files from a profile in the new profile, but be careful not to copy files corrupted to avoid transporting on the problem.

  • 2 printers - can print only a - print processor does not exist?

    I have two printers - one that I just bought.  I installed the new without any problems, that is a series of Deskjet 3510.  The other is a series of deskjet 6980.  I want to use two printers, but when I try to print the 6980 is not in the drop-down list.  I see when I look at the printers in my computer, but he can't see it when I try to print.  I tried to reinstall the 6980 and it says that the print processor does not exist.  Help, please!

    There's a troubleshooter created by HP

    Please try the HP printer installation wizard

    or use this link: www.hp.com/go/tools

  • Using NOT Exists in a query

    There must be something simple I'm missing...

    A table is used

    I need to see who registered last season but has not signed up for this season.  Whenever they sign up for a new season, it creates a new record.

    I have this

    < cfquery "doh" datasource = #datasource = name # >

    Select * from data

    where season =' #prev1.season #' and NOT EXISTS (season =' #cur1.season #')

    < / cfquery >

    looks pretty simple... but receiveing an incorrect syntax error.   It is simplying ask for all records that were played last year, 2010-2011, but there is no record of them for this year 2011-2012 meaning, that they have not registered.

    any help is GREATLY appreciated.

    Sharon

    It sounds good in theory but in practice it will be very slow.  A faster way would be:

    Select JustTheFieldsYouNeed

    from the data

    season where = #currentseason #.

    and UserId in

    (

    Select the user name

    from the data

    season where = #currentseason #.

    with the exception

    Select the user name

    from the data

    season where = #previousseason #.

    )

    Note that the keyword "except" is not supported by all of the dbs.  Sometimes you use the word "less".

  • Frequent questions: NOT IN vs NOT EXISTS

    Hi all

    Still, I don't get a clear picture of the difference between NOT IN and not exists. Can someone explain to me for example. (Pls don't give any link for reference)

    Whenever I googled for this sample as below
    with t as 
    ( select 1 empid,'arumug' name,'manager' designation,1 as mgr_id from dual
      union all
      select 2 empid,'dinesh' name,'SSE' designation, 2 as mgr_id from dual
      union all 
      select 3 empid,'SEN' name,'SSE' designation, null as mgr_id from dual
      union all
      select 4 empid,'SAM' name,'SSE' designation, null as mgr_id from dual
      )
    select * from t where t.empid not in ( select mgr_id from t)
    Yes, I returned not all values due to null values. This can be corrected as
    select  * from t  where not exists ( select mgr_id from t t1 where t1.empid=t.mgr_id)
    I can now 2 rows.

    but my doubt is the query
    select * from t where t.empid not in ( select mgr_id from t t1 where t1.empid=t.mgr_id)
    gives the same performance do not exist also.

    Can someone explain this for example...

    Pls explain

    pending

    S

    Published by: oraclehema on July 18, 2012 23:48

    In both cases the oralce converts the int of NOT IN NOT EXISTS operator and treat it.

    But just evaluates differently.

    In the first case, it uses the LNNVL and made the comparison as NOT EQUAL to.

    SQL> select * from emp e1 where e1.empno not in (select e2.mgr from emp e2)
      2  /
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 107605425
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     1 |    80 |     4   (0)| 00:00:01 |
    |*  1 |  FILTER            |      |       |       |            |          |
    |   2 |   TABLE ACCESS FULL| EMP  |     4 |   320 |     2   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| EMP  |     4 |    52 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter( NOT EXISTS (SELECT 0 FROM "EMP" "E2" WHERE
                  LNNVL("E2"."MGR"<>:B1)))
       3 - filter(LNNVL("E2"."MGR"<>:B1))
    
    Note
    -----
       - dynamic sampling used for this statement
    

    In the second case, it is exactly assessed as NOT EXISTS

    SQL> select * from emp e1 where e1.empno not in (select e2.mgr from emp e2 where e2.mgr = e1.empno)
      2  /
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 107605425
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     1 |    80 |     4   (0)| 00:00:01 |
    |*  1 |  FILTER            |      |       |       |            |          |
    |   2 |   TABLE ACCESS FULL| EMP  |     4 |   320 |     2   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| EMP  |     1 |    13 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter( NOT EXISTS (SELECT 0 FROM "EMP" "E2" WHERE
                  "E2"."MGR"=:B1))
       3 - filter("E2"."MGR"=:B1)
    

    And the condition NOT EXIST

    SQL> select * from emp e1 where not exists (select e2.mgr from emp e2 where e1.empno = e2.mgr)
      2  /
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 107605425
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     1 |    80 |     4   (0)| 00:00:01 |
    |*  1 |  FILTER            |      |       |       |            |          |
    |   2 |   TABLE ACCESS FULL| EMP  |     4 |   320 |     2   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| EMP  |     1 |    13 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter( NOT EXISTS (SELECT 0 FROM "EMP" "E2" WHERE
                  "E2"."MGR"=:B1))
       3 - filter("E2"."MGR"=:B1)
    
    Note
    -----
       - dynamic sampling used for this statement
     
    

    So when you use subquery correlated the two NOT IN and there IS NO Act in the same way.

    But even more fun is when you use NOT IN with NOT NULL check like that.

    SQL> select * from emp e1 where e1.empno not in (select e2.mgr from emp e2 where e2.mgr is not null)
      2  /
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 2487432012
    
    ---------------------------------------------------------------------------------------
    | Id  | Operation                    | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |        |     3 |   279 |     4  (25)| 00:00:01 |
    |   1 |  MERGE JOIN ANTI             |        |     3 |   279 |     4  (25)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| EMP    |     4 |   320 |     1   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | EMP_PK |     4 |       |     1   (0)| 00:00:01 |
    |*  4 |   SORT UNIQUE                |        |     2 |    26 |     3  (34)| 00:00:01 |
    |*  5 |    TABLE ACCESS FULL         | EMP    |     2 |    26 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       4 - access("E1"."EMPNO"="E2"."MGR")
           filter("E1"."EMPNO"="E2"."MGR")
       5 - filter("E2"."MGR" IS NOT NULL)
    
    Note
    -----
       - dynamic sampling used for this statement
    

    In order to check its better to use a value NULL is NOT to take advantage of a NOT IN operator.

Maybe you are looking for

  • Studies of physics, usable software?

    Hello! A Macbook is suitable for physics studies at a master level +? Software such as compatible origin and Matlab are? What Macbook should I go for? Is a sufficient Air or a pro would be most appropriate? Thank you!

  • Problem reinstalling OS on Imac 10.6.8

    Hi, I just got re [placed my hard drive failure. Before that, I have a clean copy of 10.6.8 and all data on an external drive that was taken using Time Machine. I deleted the new hard drive is visible and functional on my iMac. Basically, I couldn't

  • YouTube videos on our youth page used to autoplay in Firefox; now, nothing is there

    Our home page has videos from YouTube that are coded to auto-play. They used to do this in all browsers on Win and Mac platforms. Recently, Firefox on all platforms are no longer autoplays the video. In fact, there is selection where the video was. T

  • D7160 on OSX 10.9.3

    Just installed 10.9.3 this morning, now, the printer does not seem to be communication.   Printer preferences show that it is the default printer.  When I tried to print (several times), I get the message Order - failure to "Filter", 1 page What's ne

  • Redeclenchee HW with line Enable Pulse Train

    I am using the 'Multi-multifunction-Ctr Retrigg Train generation of impulses for the Clock.vi sample' in the Finder for example LabVIEW to sample a waveform. It worked great, but now I need to sync my purchase with another piece of equipment. The mat