开发者

how to put values into one row in sql

I make query to get customer information:

For example i would like to know from what catalogue client made orders and after query i get:

client1 ABC
client1 BCD
client1 DDD

So i would like to put all those catalogues into 1 row:

client1 ABC, BCD, DDD

SELECT clientid, catalogue FROM A 
INNER JOIN B ON A.A=B.开发者_高级运维A
WHERE orderdate > '20110101'

Is it possible to make it so?

What should i use for it?

Thank you!


TRY THIS

State (Tablename)  
City (Columnname)  
Chennai   
Madurai   
Coimbatore   

    declare @retstr varchar(8000)   
     select Top 5 @retstr = 
     COALESCE(@retstr + ';','') + City   
     from State   print @retstr   Result:

Chennai;Madurai;Coimbatore

MORE ON BELOW LINK

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜