IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Compare a column in one table to the number of entries


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
beavis

New User


Joined: 07 Mar 2008
Posts: 1
Location: India

PostPosted: Thu Sep 04, 2008 10:17 am
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Sep 04, 2008 5:12 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top