|
| Finding rows not in other tables |
 |
Thu, 07 Feb 2008 12:30:41 EST |
|
| Post Reply
|
| Re: Finding rows not in other tables |
 |
Fri, 8 Feb 2008 09:59:06 -0600 |
Garth,
SELECT COUNT(*) FROM SCHEMA.TABLEA A
LEFT OUTER JOIN SCHEMA.TABLEB B ON B.COL1 = A.COL1 ... AND B.COL7 = A.COL7
LEFT OUTER JOIN SCHEMA.TABLEC C ON C.COL1 = A.COL1 ... AND C.COL7 = A.COL7
WHERE B.COL1 IS NULL AND C.COL1 IS NULL
This query runs circles around any subselects, and gets the same results.
Rows that only exist in TABLEA are counted.
<Garth.A.Bender@WellsFargo.com> wrote in message
news:1883019854.1202405472044.JavaMail.wassrvr@ltsgwas009.sby.ibm.com...
>I have three tables with a common 7-part key. How do I structure my SQL to
>count the rows in one table that are not in either of the other two tables?
|
| Post Reply
|
|
|
|
|
|
|
|
|
|