Click here to Skip to main content
15,790,917 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've executed two select statements 

output of 1 is 

Name    Qty     Avg
AAAA     12      10.2
bbbb     10      10.5

output of 2 is 

Name    Qty2    Avg2
CCCC     10      10.5
AAAA     12      12.5

What i Actually want is 

Name   Qty    Avg   Qty2   Avg2
AAAA   12     10.2   12     12.5
bbbb   10     10.5   null   null
CCCC   null   null   10     10.5

Can Someone plz solve this Query??

Below Query will provide ur solution..

 SELECT  A.[Name]
      FROM (select name from [dbo].[1] union select name from [dbo].[2])as A
left join
[dbo].[1] AS B on A.Name =B.Name  left join [dbo].[2] AS C
ON A.Name =C .Name
Share this answer
Share this answer
Use CTE (Common table Expression) for this:-

With T1
( // first select query ),
( // second select query )
select T1.Name,T1.Qty,T1.Avg,T2.Qty2,T2.Avg2 from T1

Hope this will help you......
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900