开发者

SQL : Pivot a two text columns table?

I'm new to SQL and the Pivot function. I want to pivot the following table:

name   value
-----  -----开发者_StackOverflow中文版
name1  value1  
name2  value2  
name3  value3  

To:

name1   name2   name3  
------  ------  ------
value1  value2  value3

Any idea how I can do it? Because when I read about the pivot function it required an accumulation function, but I want to keep it as strings.


You can use a bogus aggregate function applicable to strings, such as MIN.

But you have to list the nameX columns manually, so if you want to pivot for unlimited/unknown number of columns, you'll have to dynamically construct the SQL clause.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜