SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chetanb3
Starting Member

India
49 Posts

Posted - 04/26/2012 :  08:57:16  Show Profile  Reply with Quote

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

149 Posts

Posted - 04/26/2012 :  09:01:51  Show Profile  Reply with Quote

select max(c1) as c1, max(c2) as c2, max(c3) as c3, max(c4) as c4
from yourtable
Go to Top of Page

chetanb3
Starting Member

India
49 Posts

Posted - 04/26/2012 :  09:14:03  Show Profile  Reply with Quote
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

India
22460 Posts

Posted - 04/26/2012 :  09:17:30  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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

India
47060 Posts

Posted - 04/26/2012 :  10:53:25  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000