将行转换为列时,在pivot上获取语法错误

时间:2015-04-01 17:37:15

标签: sql-server

我正在使用sql server并希望我的表行作为列,当我使用此查询进行转换时,它会给我错误的关键字

  

'1'附近的语法不正确。   这是我的查询

select strvalue,1,2
from
(select  strvalue,nSectionAttributeId,

(row_number()  over (partition by nSectionAttributeId  order by nsectionattributeid ) ) as colum
 from tblAttributeData
 )temp

 pivot
 (
 max(nSectionAttributeId)
 for colum in (1,2)
 )PIV

1 个答案:

答案 0 :(得分:0)

select strvalue,1,2
from
(select  strvalue,nSectionAttributeId,

(row_number()  over (partition by nSectionAttributeId  order by nsectionattributeid ) ) as colum
 from tblAttributeData
 )temp

 pivot
 (
 max(nSectionAttributeId)
 for colum in ([1],[2])
 )PIV