Hi, What can be an efficient way for the following problem in SQL 2008?
First two are input tables, using which I need to populate the 3rd(DataOut table)
Basically, WDATA will have zero or more rows corresponding to each row of DataIn table. I need to populate DataOut table with all the rows, including none matched and multiple matched and populate a status column differentiating between single corresponding row in WDATA, No row in WDATA, or exactly one row in WDATA.
DataIn
QID RID DOB
-------------
1 1 01/01/1980
1 2 03/01/1981
1 3 01/02/1991
WDATA(key is QID, RID,PID)
QID RID PID
---------------
1 1 101
1 1 102
1 3 204
DataOut
QID RID PID status
-----------------------
1 1 101 ”multiple match”
1 1 102 ”multiple match”
1 2 null ”no match”
1 3 204 ”single match”