robsimons
10-24-2007, 07:17 AM
Hello guys,
I'm looking for a solution for a small problem...
I have DB with 2 table... same structure in both tables... table1 is last month and table2 is this month. Currently I do not have either table setup with a PK; the "Row" below is just so you can see how the data is organized.
Tha data will basically looks like this...
TBL1 ...............TBL2
RW SSN Name.. SSN NAME
1 ...12 john .....12 john
2 ...12 john .....12 john
3 ...14 mary ....12 john
4 ...14 mary ....12 john
5 ...16 smith ....14 mary
6 ...................16 smith
7 ...................17 ronald
In my mind I am looking for a piece of code or SQL that will count SSN's (group by SSN's) from TBL1 and compare that to the count of SSN's (grouped by SSN's) from TBL2 if the TBL1.count.ssn != TBL2.count.ssn then copy(or move) the "Extra" rows to another table (or report)?
So for the above example TBL1.count.12(ssn) = 2 and TBL2.count.12 = 4 since the 2 != 4 (how do you like that??? my math is getting better:rotlaugh:), I would like RW=3&4 copied(moved) to a new table.
I already have piece of SQL to find the unique(New) rows in TBL2. This example SSN = 17.
Any questions?
Thanks
I'm looking for a solution for a small problem...
I have DB with 2 table... same structure in both tables... table1 is last month and table2 is this month. Currently I do not have either table setup with a PK; the "Row" below is just so you can see how the data is organized.
Tha data will basically looks like this...
TBL1 ...............TBL2
RW SSN Name.. SSN NAME
1 ...12 john .....12 john
2 ...12 john .....12 john
3 ...14 mary ....12 john
4 ...14 mary ....12 john
5 ...16 smith ....14 mary
6 ...................16 smith
7 ...................17 ronald
In my mind I am looking for a piece of code or SQL that will count SSN's (group by SSN's) from TBL1 and compare that to the count of SSN's (grouped by SSN's) from TBL2 if the TBL1.count.ssn != TBL2.count.ssn then copy(or move) the "Extra" rows to another table (or report)?
So for the above example TBL1.count.12(ssn) = 2 and TBL2.count.12 = 4 since the 2 != 4 (how do you like that??? my math is getting better:rotlaugh:), I would like RW=3&4 copied(moved) to a new table.
I already have piece of SQL to find the unique(New) rows in TBL2. This example SSN = 17.
Any questions?
Thanks