I frequently have a need to compare two datasets to see what rows are different. In Excel, with a small dataset, it's easy enough to concatenate the fields I want to compare, then countif() that new field matches the value of my other dataset row by row. But, when the dataset gets too large, it crashes Excel, of course. I've always thought it was a bit of a hack way of doing it, and I'd like to know a more appropriate way to do it in SQL.
So, here's a more visual example: Dataset Original
Abc, 123, 1/1/1900
A23, 4.5, 2/1/1900
New Comparison Dataset
Abc, 123, 1/1/1900
A23, 4.6, 2/1/1900
Dataset Original in Excel
Abc, 123, 1/1/1900, =concatenate(A1,B1,C1), =countif('New'!D:D,C1)
A23, 4.5, 2/1/1900, =concatenate(A2,B2,C2), =countif('New'!D:D,C2)
New Comparison Dataset in Excel
Abc, 123, 1/1/1900, =concatenate(A1,B1,C1), =countif('Original'!D:D,C1)
A23, 4.6, 2/1/1900, =concatenate(A2,B2,C2), =countif('Original'!D:D,C2)
If I filter by the last column in both sheets, I get the two different rows, and can see that one has 4.5 and the other has 4.6.
I'd like to not only be able to see the two sets of unmatched records, I need to also be able to compare them based on only certain fields/columns matching, not necessarily the whole row.
I have a feeling the answer is similar to using =sumproduct(--(field=value),--(field<value),range)
which is another way I compare things in smaller Excel datasets.
Thanks for the assistance.