Skip to content
Advertisement

Evaluate Multiple conditions for same row

I have to compare 2 different sources and identify all the mismatches for all IDs

Source_excel table

Source_dw table

Expected result

I have tried the below query but it is giving only one mismatch.

Actual output

I understand that case expression will only check the first satisfying condition. Is there any other way I can check all the condition?

Advertisement

Answer

If I follow you correctly, you want one row per mismatch, or one row indicating that everything matches.

You can use cross apply to generate the rows, like so:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement