i have two temporary table
Table 1
ID1 Name ID2 Single
----------------------------------------------------
1 ABC 1 100
2 DEF 1 200
Table 2
ID1 Name ID2 Monthly
----------------------------------------------------
3 PQR 2 500
4 LMN 2 600
1 ABC 2 700
2 DEF 2 800
I want Output
ID1 Name ID2 Single Monthly
--------------------------------------------------------
1 ABC 1 100 700
2 DEF 1 200 800
3 PQR 2 NULL 500
4 LMN 2 NULL 600
I used all Joins , Union ALL , Union nothing working
thanks in advance
Hope you are using Sql Server 2008(other wise the insert statement in my query won’t work). Try this one.
From the required out put, i guess you need all the values from table2 and there corresponding Single(Column name in table 1) value.