find discrepancy between two tables

  • Hi Experts,

    I have to find discrepancy between two tables

    I have Table 1 with columns

    OrderID

    Date

    Quantity

    Symbol

    Table 2 with columns

    OrderID

    Date

    Quantity

    Symbol

    I want a script to find out a list of OrderIDs present in table1 but not in table 2 and a list of OrderIDs present in table2 but not in table 1.

    Could any one help me in writing this query?

    Thanks in advance

  • Try this:

    select OrderID, Date, Quantity, Symbol from table1 where not exists(select * from table2 where OrderID = table1.OrderID) -- rows present in table1 that aren't in table2

  • hi ,

    write a select query using a full outer join between the two tables on orderid where orderId is null

    will select only the differnce in orderId between the two tables

    Regards,

    Rajesh

  • Thanks for the script , it is working fine

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply