2
我想做一個相當符號的樞軸。這一次運行正常:sql pivot函數不允許整數作爲列名嗎?
with cte as
(
select Symbol, TradeDate, 'Per' + cast(Period as CHAR(3)) Per, Value
from tblDailySMA
)
select * from cte
pivot
(Max(Value) for Per in (Per5,Per10,Per15,Per20,Per30,Per40,Per50,Per60,Per80,Per100,Per110,Per120,
Per150,Per200)) pvt
而這一次給出了錯誤Incorrect syntax near 5
(並突出顯示的第一個值(5)後「的時期」:
with cte as
(
select Symbol, TradeDate, Period, Value
from tblDailySMA
)
select * from cte
pivot
(Max(Value) for Period in (5,10,15,20,30,40,50,60,80,100,110,120,150,200)) pvt
我得到的第一個多試錯後運行...有一個原因,如沒有被允許作爲列名的感謝也許整數值..
但當然。謝謝.. – StatsViaCsh