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
 combining multiple rows into single column sql

Author  Topic 

tandel
Starting Member

2 Posts

Posted - 2011-07-06 : 08:14:57
hello,

I want to combine resulted 3 column into 1 comlumn, please help me.

SELECT DAS_Card_Archive.Das_Card_ID as [Das Card ID], DAS_Card_Line.Das_Card_ID as [Das Card ID],
DAS_Card_Session.Das_Card_ID as [Das Card ID]
FROM DAS_Card_Archive FULL OUTER JOIN
DAS_Card_Line ON DAS_Card_Archive.Das_Card_ID = DAS_Card_Line.Das_Card_ID FULL OUTER JOIN
DAS_Card_Session ON DAS_Card_Line.Das_Card_ID = DAS_Card_Session.Das_Card_ID

Result
Das Card ID Das Card ID Das Card ID
----------- ----------- -----------
5 NULL NULL
6 NULL NULL
NULL 1 NULL
NULL 2 NULL
NULL 4 NULL
NULL NULL 7
NULL NULL 8
NULL NULL 9

i want result
Das Card ID
-----------
5
6
1
2
4
7
8
9

please help me..
thanks in advance..

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-07-06 : 08:21:42
SELECT Das_Card_ID = coalesce(DAS_Card_Archive.Das_Card_ID, DAS_Card_Line.Das_Card_ID, DAS_Card_Session.Das_Card_ID)
FROM DAS_Card_Archive
FULL OUTER JOIN DAS_Card_Line
ON DAS_Card_Archive.Das_Card_ID = DAS_Card_Line.Das_Card_ID
FULL OUTER JOIN DAS_Card_Session
ON DAS_Card_Line.Das_Card_ID = DAS_Card_Session.Das_Card_ID



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

tandel
Starting Member

2 Posts

Posted - 2011-07-06 : 08:30:43
thanks you nigelrivett........ cheers
Go to Top of Page
   

- Advertisement -