抱歉 - 我的问题标题可能与我尝试这样做时一样无能。
我在 CMS 的表格中有以下内容(嗯,类似)
pageID key value
201 title Page 201's title
201 description This is 201
201 author Dave
301 title Page 301's title
301 description This is 301
301 author Bob
正如您可能已经猜到的,我需要的是一个将生成的查询:
pageID title description author
201 Page 201's title This is page 201 Dave
301 Page 301's title This is page 301 Bob
如果有人可以提供帮助,我将永远感激不已 - 我知道这是“请向我发送代码”,但我完全陷入困境。
提前致谢。
最佳答案
Select PageId
, Min( Case When key = 'title' Then Value End ) As Title
, Min( Case When key = 'description' Then Value End ) As Description
, Min( Case When key = 'author' Then Value End ) As Author
From Table
Group By PageId
关于sql - 将每行中带有标识参数的表行 SQL SERVER 2008 转换为单行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2733830/