反反轉欄位

--反反轉欄位

SELECT io_month, pay_id

FROM

--反轉欄位

(SELECT io_month, [I22], [I23], [M02], [M03]

FROM

(SELECT io_month, pay_id, item_money FROM pay_employee WHERE employee_id = '103183'

AND io_month IN ('201609', '201610')

AND pay_id IN ('I23', 'M03', 'M02', 'I22')) AS pay

pivot

(sum(item_money)

FOR pay_id IN ([I22], [I23], [M02], [M03])

) AS id) AS temp

UNPIVOT(

pay_name FOR pay_id IN ([I22], [I23], [M02], [M03])

) upv