SQL exclude records found in

I have the following SQL, how do I change the second JOIN, to exclude the same record already found in the first select statement. I don't want to add the same record twice (which could happen, because I might return different Marketing_channel information per join) ie how do I add the "not exist" code to the second join. I am having syntax issues doing this. Thanks in Advance
sel A.PARTY_ID, A.cust_prod_sub_id, A.EVENT_DT, B.Marketing_channel from
(Select
PARTY_ID,
cust_prod_sub_id,
event_dt,
SALES_DEALER_NO,
SALES_AGENT_NO
From
tabletwo ) as A
JOIN
(Select MARKETING_CHANNEL, SALES_AGENT_NO
From tableone
Where dealer_flag = 1
) as B
on a.SALES_DEALER_NO = b.SALES_AGENT_NO
UNION
sel A.PARTY_ID, A.cust_prod_sub_id, A.EVENT_DT, B.Marketing_channel from
(Select
PARTY_ID,
cust_prod_sub_id,
event_dt,
SALES_DEALER_NO,
SALES_AGENT_NO
From
tabletwo ) as A
JOIN
(Select MARKETING_CHANNEL, SALES_AGENT_NO
From tableone
Where agent_flag = 1
) as B
on a.SALES_agent_NO = B.SALES_AGENT_NO
--(I am guessing I have to add not exist statement here)

You want something like this?
WITH T1 AS  (SELECT 1 ID, 1 DAT FROM DUAL
   UNION ALL SELECT 2, 2 FROM DUAL
   UNION ALL SELECT 3, 3 FROM DUAL),
         T2 AS  (SELECT 2 ID, 1 DAT FROM DUAL
   UNION ALL SELECT 3, 2 FROM DUAL
   UNION ALL SELECT 4, 3 FROM DUAL)
SELECT 1 SRC, T1.*
FROM T1
WHERE T1.ID = :ID
UNION
SELECT 2 SRC, T2.*
FROM T2
WHERE T2.ID = :ID
AND NOT EXISTS
  (SELECT 1
   FROM T1
   WHERE T1.ID = :ID)for all values of ID between 1 and 3 it returns just the record from table T1. when ID = 4 it returns the record from T2.

Similar Messages

  • Integrity constraint child record found

    TopLink Version: Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070323)
    I may be going crazy here, but I keep getting an integrity constraint when I try to delete an object that has 1:M relationship (Resource 1:M Attribute):
    Internal Exception: java.sql.SQLException: ORA-02292: integrity constraint (WEBCENTER.WP_RELATIONSHIP_RES_FK) violated - child record found
    The child object attribute is set to "Private Owned", and there is an FK from the child table to the parent table in the database (this is where the integrity constraint violation is coming from).
    I query for the Resource, register it in the unit of work, call UOW.deleteObject(resource), and then call UOW.commitAndResume(). TopLink is making a sql call to delete the Resource, but it does not first delete the privately owned Attributes which results in the FK violation.
    It should delete the child records first, right?
    In addtion to having the attribute set to "Private Owned", I also have set:
    Batch Reading
    Use Indirection
    Transparent
    Not sure if that makes a difference.

    Use a trigger. Example:
    CREATE OR REPLACE TRIGGER update_parent_chilren
    BEFORE UPDATE OF pkey_column ON parent_table
    FOR EACH ROW
    BEGIN
    UPDATE child_table
    SET fkey_column = :NEW.pkey_column
    WHERE fkey_column = :OLD.pkey_column;
    END update_parent_children;
    null

  • Duplicate record found short dump, if routed through PSA

    Hi Experts,
    I am getting these errors extracting the master data for 0ACTIVITY
    1 duplicate record found. 1991 recordings used in table /BI0/XACTIVITY
    1 duplicate record found. 1991 recordings used in table /BI0/PACTIVITY
    2 duplicate record found. 2100 recordings used in table /BI0/XACTIVITY
    2 duplicate record found. 2100 recordings used in table /BI0/PACTIVITY.
    If I extract via PSA with the option to ingnore duplicate records, I am getting a short dump
    ShrtText                                            
        An SQL error occurred when accessing a table.   
    How to correct the error                                                             
         Database error text........: "ORA-14400: inserted partition key does not map to  
          any partition"                                                                  
    What is  causing errors in my extraction ?
    thanks
    D Bret

    Go to RSRV .Go to All Elementary Tests -->PSA Tables -->Consistency Between PSA Partitions and SAP Administration Information## ..and correct the error...

  • No matching records found ' Payment Terms ' (OCTG) (ODBC -2028)

    Hi Everyone,
    I upgraded a customers database to from 2007 pl05 to 8.8 pl20. After successfully creating an outgoing payment by Account (not vendor or Customer), when i try to print it comes up 'No matching records found ' Payment Terms ' (OCTG) (ODBC -2028)'. If its a Vendor or Customer outgoing payment it lets me print.
    What could that be?
    Thanx in advance,
    Leonardo Martinez
    Solution Consultant

    Hi Leonardo......
    Please Go to Administration> System Initialization> General Setting> BP Tab> Payment Terms should not be -1. Please assign some actual Payment Terms.
    Also please check the business partner master data Payment Terms Tab It should also not be -1 it should be some value.
    Also please check OCTG table in SQL........
    Regards,
    Rahul

  • SQL*Loader records won't delete

    I am mystified. A P/A is developing a conversion of legacy data into a new archive db. He runs data in using SQL*loader into our 7.3.4 database, but when we try to delete one of those records, it rolls back even though our explicit commit returns with 'commit completed'.
    Our test is to load record 'a', select 'a': 1 records found, delete 'a':one record deleted, select 'a': 0 records found, commit:commit completed, select 'a':1 records found.
    Non-loaded records delete fine.
    Is something corrupted in rowid, or other metadata? DOES ANYONE HAVE AN IDEA?

    check if the change date is outside your entered date range

  • How to show 'No Records Found' and 'Employee Name Unknown' in oracle report

    Hello,
    I'm using 6i and building a report to show employees who have incorrectly input their time. I have an input parameter so a user can select a specific employee by emp_id or can leave it empty to show all. That part works. I also have date parameters that are required. That works too. However I am having trouble displaying 'NO Records Found' if the date parameters have no late or rejected employee time records. I currently have it as a text field arranged behind the emp_name field which i filled white. It works...however i have a pretty good feeling there is a better way to do this. Also, I have some data that is null since i am using two tables. There are time stamps with no emp_name or emp_number. I still need to show these records but want them to show up as "Employee Name Unknown" that way the user doesnt get confused and thinks the emp_name in the row above also includes this row.
    select e.location "Clock Location",
    e.emp_no "Emp No",
    l.first_name ||' ' || last_name "Name",
    e.time_stamp "Time",
    from emp_time e, master_all l
    where e.emp_no (+) = l.emp_no
    and e.status = 'rejected'
    --and e.emp_no  = nvl (:p_emp_no, emp_no)
    --and e.time_stamp between :p_start_date and :p_end_date                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hi,
    So, when the join between emp_time and master_all produces no rows, you still want one row of output, saying 'No Records Found'; is that right?
    If so, you can outer-join the result set to dual, with some join condition that accepts anything.
    Use CASE (or equivalents) to get special values (like 'No Record Found' or 'Employee name unknown') when certain columns are NULL.
    For example:
    SELECT     j.location     AS "Clock Location"
    ,     j.emp_no     AS "Emp No"
    ,     CASE
              WHEN  j.name     IS NULL
              THEN  'No Records Found'
              ELSE  j.name
         END          AS "Name"
    ,     time_stamp     AS "Time"
    FROM     dual     d
    ,     (     -- Begin in-line view j, join of emp_time and master_all
              SELECT     e.location
              ,     e.emp_no
              ,     CASE
                       WHEN  l.first_name IS NULL
                       AND       last_name    IS NULL
                       THEN  'Employee name unknown'
                       ELSE  l.first_name || ' ' || last_name
                   END     AS name
              FROM      emp_time     e
              ,     master_all     l
              WHERE     e.emp_no (+)       = l.emp_no
              AND      e.status (+)       = 'rejected'
    --           AND     e.emp_no (+)        = NVL (:p_emp_no, emp_no)
    --           AND       e.time_stamp (+)  BETWEEN :p_start_date
                                             AND        :p_end_date
         ) j     -- End in-line view j, join of emp_time and master_all
    WHERE     d.dummy     != j.name (+)
    ;In an outer join, all conditions involiving the optional table need a + sign; otherwise, the effect is the same as an inner join.
    The message 'No Records Found' is a string, so it has to go in a string column.
    I put it in the "Name" column, just because I knew that "Name" was a string.
    You can put in in any other column if you wish. If that column is not already a string, then use TO_CHAR to make it a string.
    You could also have a column just for this message.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    DOUBLE U wrote:
    I've tried nvl in the select statement but since emp_name is a concatination of first and last name it doesnt work. This is what i have tried
    nvl(l.first_name|' '||l.last_name,'NO EMPLOYEE RECORD FOUND') "Employee",I assume you meant to have two | characters, not just one, after first_name.
    The first argument to NVL will never be NULL in that case; it will always contain at least a space, whether or not the other columns are NULL. You could say:
    NVL ( NULLIF ( l.first_name || ' ' || l.last_name
        , 'NO EMPLOYEE RECORD FOUND'
        )        "Employee",bujt I find it less confusing to use CASE, as shown above.

  • No Matching Records Found ''G/L Account''

    Dear All ,
    I am Posting A/P Invoice which is based on GRPO, but while adding document system is showing the following error
    No Matching records found ''G/L Accounts'' (OACT) (ODBC-2028) [Message 131-183].
    The G/L Account determination is Item Group wise and i have checked the Account determination in Item Group everything is fine and i would like to know the Possible reasons for this error.
    Regards,
    Kashi

    Hi,
    Kindly check the following settings :
    1. Check the G/L account setting of the item.
    If managed by Warehouse, then check warehouse -> Accounting tab.
    If item group, then check item group -> accounting tab.
    If item level, then check the item master data.
    Defined all acccounts for the warehouse/item group/item.
    2. Check administration -> setup -> financials -> G/L Account Determination -> General tab. Define the Rounding Account.
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • A\R Invoice. No matching record found

    Hi,
    2004C, PL69.
    User creates A\R Invoice and payment at once. When he tries to add A\R invoice to system he gets message: u201C[OINV], no matching record found A\R Invoice (ODBC-2028)u201D. If I (other user) do the same it runs smoothly, moreover when I made a backup of database and restored it to other database and  entered it as that user it ran smoothly too. what should I do to solve this problem?
    With regards
    Maxim Groonis

    This seems to be a strange system behaviour.  If you are able to move ahead by using the other user account to post the AR Invoice + Payment, you should just continue without worrying about the error.
    In the meanwhile I would suggest that you report this to SAP by opening a Support message so that they could investigate on the causes.
    Suda

  • Error in adding A/R Invoice - 'No Matching Records Found'

    Hi Folks,
    This one is related to 'thunderclap8's post last month (June 01, 2011)
    As we create an A/R Invoice, we have encountered an error that says:
    [A/R Invoice  Rows  Warehouse Code] [line: 0] , 'No matching records found  'Inventory Log Message' (OILM) (ODBC -2028)'  [Message 131-183]
    As with the process, the supposed A/R Invoice we're making came from a Delivery/Release that came also to a Sales Order.
    But when we make the same transaction for other Customers, it ends successfully. I'm not trying to point out that it's because of the Customer since the error shows inventory-related concern.
    Any theory on how did it come to this? and any remedy?
    Thanks!
    Fringe

    Hi Raja!
    First and foremost, I would like to thank you for your answer.
    I have checked it and there are no restrictions involved with the item nor with the BP.
    I can't exactly determine the cause of this error.
    I believe you do have other suggestions, don't hesitate to post it here.
    Thanks!
    Fringe

  • No matching record found G/L Account (OACT) A/P Credit Memo

    Hello Experts,
                                   When i post A/P Credit Memo i get message as No matching record found G/L Account (OACT).
                                    Version SAP B1 8.8 PL11
    I tried following
       check  the rounding account In G\L determination.
       check  the offset account in G\L determination.
    everything is properly set.
    We did upgrade from 2007B to SAP B1 8.8
    Please Suggest
    Quick reply will be helpful

    Hello Gordon & Sachin,
                                                                                    I have even tried in test system , same error it gives,
                                                   I have check the Purchase return , Purchase credit and Expense Account , everything is
                                                   properly set.
                                                   When i do copy to from A/P Invoice , it is getting added                                                                               
    One more error it gives mewhen  i load or open   the from of Purchase A/p credit Memo, it
                                                  Gives error in red color as "Divide By zero error encountered (NFN1)
    Please Suggest

  • No Matching records found (OACT) - A/P Credit Memo

    Hi Experts
    When i try to post an A/P Credit memo, SAP B1 gives an error No Matching records found (OACT). i checked all the account determination. could not find anything any suggestions to solve this problem.
    Thanks in advance
    Kanishka Wickrama

    Hi Kanishka,
    in addtion to the ususal accounts necessary for transactions involving stock you also need to define the Sales & Purchase credit accounts. Also, you might check whether there is a freight charge that needs to be credited or if a different tax code is used. Even if the tax rate is zero, the application will look for an account to be defined.
    There could be a multitude of other reasons which are documented in the EES : GL Account missing, which is available [here|https://psd.sap-ag.de/PEC/calendar/html/recording.php?hck=3163a8d6a4540ecf1794ece0245f291154d30e1080359d2e994ef79c1a469aa0cd808769d9c7ee30ca342c6803d2ebcec3eb71a928d6db187dfb1fc2cf640395].
    All the best,
    Kerstin

  • No matching record found 'G/L Accounts'

    Hello,
    When I try to copy an A/P Credit memo from an A/P invoice, the following error message appears: "No matching record found 'G/L Accounts' (OACT)[ODBC 2028]"
    This message appears only when I select some lines from the credit memo. If I choose all lines, the credit memo is created.
    SAP 8.8 PL 18
    Any idea please?

    Hi NADIA BENLAMLIH,
    Check This Link.
    http://forums.sdn.sap.com/search.jspa?threadID=&q=Nomatchingrecordfound%27G%2FL+Accounts%27&objID=f264&dateRange=all&numResults=15&rankBy=10001
    Generaly this type Error occured for the G/L Account Determination check it.
    Thanks,
    Srujal Patel

  • 36 duplicate record  found. -- error while loading master data

    Hello BW Experts,
    Error while loading master data
    ( green light )Update PSA ( 50000 Records posted ) No errors
    ( green light )Transfer rules ( 50000  „³ 50000 Records ): No errors
    ( green light )Update rules ( 50000 „³ 50000 Records ): No errors
    ( green light ) Update ( 0 new / 50000 changed ): No errors
    ( red light )Processing end: errors occurred
         Processing 2 finished
    ƒÞ     36 duplicate record found. 15718 recordings used in table /BIC/PZMATNUM
    ƒÞ     36 duplicate record found. 15718 recordings used in table /BIC/XZMATNUM
    This error repeats with all the data-packets.
    what could be the reason of the error. how to correct the error.
    Any suggestions appreciated.
    Thanks,
    BWer

    BWer,
    We have exactly the same issue when loading the infoobject 0PM_ORDER, the datasource is 0PM_ORDER_ATTR.
    The workaround we have been using is 'Manual push' from the details tab of the monitor. Weirdly we don't have this issue in our test and dev systems, even in Production, this doesn't occur somedays. We have all the necessary settings enabled in the infopackage.
    Did you figure out a solution for your issue, if so please let me know and likewise I will.
    -Venkat

  • Creating a Good Receipt PO via DI API No matching records found (ODBC -2028)

    Hi,
    I trying to create a Good Receipt PO via DI API.  It is working when the user I used to log in to SAP via the DI API is a Professional User but when I changed it to a Limited Logistics User, I'm receiving the No matching records found (ODBC -2028). I have already added the SDK Tools license to that user but still I'm receiving that error.
    So is it that the DI API will only work with a Professional User license or I can still use a Limited Logistics User?

    HI J S L,
    I get same error when I use different user that I just now add the SDK Tools without restarting the database server.  But previous user that I added SDK Tools before restart, no error.
    Today
    User 1 - add SDK Tools, no restart, error
    Last Wednesday
    User 2 - add SDK Tools, no restart, error
    Today - database server restarted this morning
    User 2 - no more error
    Both User 1 and 2 are Limited Logistics User.
    Best regards,
    Dennis

  • No matching records found Goods receipt PO (OPDN) (ODBC-2028) [Message 131-

    Hello,
    We are having a problem viewing one of our goods receipt. When going into a PO weu can see that there is a target document, but when we click on it the following message pops up u2013 u2018No matching records found Goods receipt PO (OPDN) (ODBC-2028) [Message 131-183]u2019. You cannot view the goods receipt by going through the purchasing module either. You can however see it when you go into the item and then right click and choose u2018stock posting listu2019. It then shows the goods received from GRPMS at the bottom under the GR no
    We now have the invoice and need to enter it onto SAP but because you cannot view the GRN it wonu2019t allow me to copy from the GRN.
    Could some offer assistance.
    Regards,
    Juan

    Dear Juan82,
    From what you say it looks like it is an issue that should be reported by message in order to be fixed.
    Please, log a message on the portal with your S number.
    When you write the description of the issue please attach screenshots that can help us to understand the issue.
    Regards,
    Marcella Rivi
    SAP Business One Forums Team

Maybe you are looking for

  • I do not know my pin number what do I do?

    I have been getting blocked calls and it has been getting annoying. I finally found a website that reveals the caller and it needs the pin number. But I have no idea what it is.

  • Acrobat X save metadata to XMP file problem

    I am having no luck saving metadata from a PDF to an XMP file using Acrobat X. This has worked properly for me in previous versions of Acrobat, but since upgrading to Acrobat X 10.1.7 the XMP file is given no name automatically, and when saved is zer

  • Accepted at Origin - process

    Question from MM Colleage: Have you used the 107 and 109 movement types before? My understanding is that the accept at origin box is checked at the line item level on the delivery tab of the PO to leverage these 2 movement types. An inbound delivery

  • Cron, Date and `

    I'm trying to schedule an scp of a file from one server to another, and append a current date to it, like so: 30 5 * * 0 scp /directory/file.bak admin@server:/directory/file.bak.`date +%m%d%y` This scp works from the command line, but cron doesn't li

  • Link in Portfolios

    Hallo Ist es möglich von einer bestimmten Seite eines PDF-Formulars auf eine bestimmte Seite eines anderen PDF-Formulars innerhalb eines Portfolios zu verlinken? Wenn ja, wie? Vielen Dank