Hi Experts,
I have 2 tables as below:
First table: ConsumerID (PK, nvarchar(50), DatasetID (int))
Second table: ConsumerID (PK, nvarchar(50), DatasetID (int))
and I want to have the code snippet to figure out all cases below:
- Find all DatasetID that exists in first table and HAS matched DatasetID in second table for each ConsumerID.
- Find all DatasetID that exists in first table and DOESN'T has matched DatasetID in second table for each ConsumerID.
- Find all DatasetID that exists in second table and DOESN'T has matched DatasetID in first table for each ConsumerID.
- Find all DatasetID that exists in first table UNION DatasetID in second table for each ConsumerID.
Please note that:
- ConsumerID are same for first and second table.
- Results should be one row ONLY for each consumer and resulted datasets are "separated by comma".
Thanks a lot in advance.
Harreni