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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 help needed with the following query

Author  Topic 

raaj
Posting Yak Master

129 Posts

Posted - 2011-09-02 : 01:49:08
Hi Guys,
I have written a query and sample output is something similar to the below :
User col1 col2 col2
ABC 100 NULL NULL
ABC NULL 200 NULL
ABC NULL NULL 300

Now i want to write a query where the output should look like :
User Col1 Col2 Col3
ABC 100 200 300

Any suggestions please.....

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-02 : 01:58:04
[code]SELECT User,
MAX(col1) AS col1,
MAX(col2) AS col2,
MAX(col3) AS col3
FROM Table
GROUP BY user
[/code]

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

Go to Top of Page

raaj
Posting Yak Master

129 Posts

Posted - 2011-09-04 : 20:01:57
Thanks visakh....
that worked perfectly........
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-04 : 21:36:55
welcome

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

Go to Top of Page
   

- Advertisement -