Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to get data as a new column wise with multiple

Author  Topic 

dhani
Posting Yak Master

132 Posts

Posted - 2009-04-03 : 19:10:02
Query 1
=======

Select info,recNum from HoldRecs inner join holdrecsdefinitions on Holdrecs.id=Holdrecsdefinition.id where submit=1089 and id=10889
union
Select info,recNum from HoldRecs where submit=2082 and id=1889

Result of Query 1
=============

info,RecNum
-------------
1,10
2,12
3,14
4,16
It Park,18
King Hotel, 20
,21


Query2
========

Select info,recNum from HoldRecs where submit=2082 and id=1889
union
Select info,recNum from HoldRecs where submit=2082 and id=1889

info,RecNum
-------------
Emerald Sq,10
Green Elizabeth,12
Good Ofa,14
MenloPark,16
Kubusa,18
Zing, 20
,21



now the question is how can i get the all first query data with second query first column(info column alias as address) as third column in query 1

so expected output will be as below
if i use union it gives the result below the column (i need it as row wise)

info,RecNum,address
----------------------
1,10,Emerald Sq
2,12,Green Elizabeth
3,14,Good Ofa
4,16,MenloPark
It Park,18,Kubusa
King Hotel, 20,Zing
,21,


Please help me, any ideas

please, really appreciate it

Best Regards
asini

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-04-03 : 23:46:30
Your query doesn't make sense. Your 2nd query consist of same statement with union(which is not required)? Also your Ist query should have result for 2nd query as well.
Go to Top of Page
   

- Advertisement -