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 2008 Forums
 Transact-SQL (2008)
 grouping issue

Author  Topic 

vipinjha
Starting Member

21 Posts

Posted - 2012-01-30 : 05:33:35

Dear Sir ,
I want to see record in sql like below
suppose i have diffrent type like A ,B
each having multiple data
i wanna see each data in single row


TYPE DATA
A 1
A 2
A 3
B 4
B 5

PLZX GUGGEST


Regards,
Vipin jha


Vipin jha

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2012-01-30 : 05:54:06
What do you mean a single row? Do you mean you want to PIVOT the results? if so, there are many examples of how to use pivot for this kind of issue. A couple of easy ones to follow:

http://blogs.msdn.com/b/craigfr/archive/2007/07/03/the-pivot-operator.aspx

http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-30 : 11:26:55
may be this?


SELECT [Type],
STUFF((SELECT ',' + DATA FROM table WHERE [TYPE] = t.[TYPE] ORDER BY [DATA] FOR XML PATH('')),1,1,'') AS datavalues
FROM (SELECT DISTINCT [TYPE] FROM table)t


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

Go to Top of Page
   

- Advertisement -