View previous topic :: View next topic
|
Author |
Message |
beavis
New User
Joined: 07 Mar 2008 Posts: 1 Location: India
|
|
|
|
Hi,
I have two tables. I must compare a column in one table to the number of entries in the other under the same Identification number.
Eg:
Table 1 has a value of 5 under "col A" for a particular record.
Therefore table 2 must have 5 rows with the same ID number as the table 1 row.
Now using a join I have listed all the rows which have mismatches between Table 1 & Table 2.
Eg:
Table 1 has a value of 5 under "col A" for a particular record.
Table 2 has ONLY 4 rows with the same ID number as the table 1 row. Therefore this is a mismatch and the output file displays the ID number of the mismatched row.
My query is how do I generate a count for the number of mismatches?
Help would be appreciated :) |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
If i understud correctly table1 has id A and val as 4 so in table 2 there has to be 4 rows of A and you want this A to be displyed if no of rows in table2 is not 4 right ? if yes then
Code: |
SELECT ID FROM TABLE1 A WHERE VAL <>
(SELECT COUNT(*) FROM TABLE2 WHERE ID = A.ID)
|
|
|
Back to top |
|
|
|