sql server - Combine different columns from 2 different queries into one resultset -
there many similar questions not wanted i'm reserved asking question forgive me if duplicate couldn't find precisely wanted.
i have query:
select top 1 t1.col1, t1.col2, <need_to_append_here> t1 left outer join t2 on t1.id = t2.id t1.id = 'x' order t2.col2 desc
where see need_to_append_here, need different sql appended result 4 columns in result set:
select t3.col3, t3.col4 t3 t3.id = 'z'
i should see 1 row col1, col2, col3, col4
update able work single column 2nd query doing like
select * (select top 1 t1.col1, t2.col2, (select t3.col3..) col3 ....
but i'm unable include 2 columns in 2nd select
you can join (or left join) since you're doing top 1
select top 1 t1.col1, t1.col2, t3.col3, t3.col4 t1 left outer join t2 on t1.id = t2.id left outer join t3 on t3.id = 'z' t1.id = 'x' order t2.col2 desc
Comments
Post a Comment