gary.morey (12/9/2013)
I have 2 tables. Each one has the following columns: SSN, PKT and FICE_NBR.I need to be able to retrieve the rows from table A where the combo of SSN and PKT and FICE_NBR in table A do not equal the combo of SSN and PKT and FICE_NBR in table B. Each of the tables has approx. 4 million rows.
I need to be able to include all of the columns from table A in the result set. The columns from table B are not required in the result set.
Any thoughts on the best way to write the SQL for this query?
Any help would be appreciated.
you can go like this:
SELECT SSN , PKT , FICE_NBR
FROM A
WHERE SSN + PKT + FICE_NBR
NOT IN (
SELECT SSN + PKT + FICE_NBR
FROM B
)
and for the duplicates a DISTINCT is enough i think
like:
SELECT DISTINCT SSN , PKT , FICE_NBR
FROM BLAH ...