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
 Query help

Author  Topic 

chetanb3
Yak Posting Veteran

52 Posts

Posted - 2012-04-26 : 08:57:16

My current result set is like belwo
c1 c2 c3 c4
-------------------------------
A NULL NULL NULL
NULL B NULL NULL
NULL NULL C NULL
NULL NULL NULL D

I wand to combine rows in to single row like below please help..

c1 c2 c3 c4
-------------------------------
A B C D

singularity
Posting Yak Master

153 Posts

Posted - 2012-04-26 : 09:01:51
[code]
select max(c1) as c1, max(c2) as c2, max(c3) as c3, max(c4) as c4
from yourtable
[/code]
Go to Top of Page

chetanb3
Yak Posting Veteran

52 Posts

Posted - 2012-04-26 : 09:14:03
quote:
Originally posted by singularity


select max(c1) as c1, max(c2) as c2, max(c3) as c3, max(c4) as c4
from yourtable




thanks..
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-04-26 : 09:17:30
What do you want to return if your current result set is like below

c1 c2 c3 c4
-------------------------------
A NULL NULL NULL
NULL B NULL NULL
NULL NULL C NULL
NULL NULL NULL D
K NULL NULL NULL
NULL L NULL NULL
NULL NULL A NULL
NULL NULL NULL P


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-26 : 10:53:25
quote:
Originally posted by chetanb3

quote:
Originally posted by singularity


select max(c1) as c1, max(c2) as c2, max(c3) as c3, max(c4) as c4
from yourtable




thanks..


doesnt make any sense to me to merge data like this unless you've another related field based on which you do the merge

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -