user2201789
user2201789

Reputation: 1211

SQL to find discrepancy between 2 tables with same identifier

I'm trying minus command but not working

Compare using column ID in both table, e.g. table A ID 1 Date vs Table B ID 1 Date

Is it possible to list both tables in one view?

Upvotes: 1

Views: 656

Answers (2)

nzpablo
nzpablo

Reputation: 41

SELECT tb1.ID, tb1.Date, tb2.Date 
FROM table1 as tb1 
    INNER JOIN table2 as tb2 
        on tb1.ID = tb2.ID 
WHERE tb1.Date <> tb2.Date

only shows dates that are different. does not take into account that an id could be missing on either table

Upvotes: 1

Kaushik Nayak
Kaushik Nayak

Reputation: 31676

You should use a TRUNC() function on the date column. The dates may be same but since time is different MINUS is treating it as 2 different dates.

Upvotes: 0

Related Questions