我有下面的表格,我正在寻找枢轴,以便第1列中的描述成为新枢轴中的列标题.
Nominal Group | GrpID | Description | Value | CustomerID
---------------+-------+-----------------+-------------+-----------
Balance Sheet | 7 | BS description | 56973.10 | 2
Cost of Sales | 4 | COS description | 55950.17 | 2
Sales | 1 | Sales | -178796.18 | 2
Labour Costs | 5 | Wages | 18596.43 | 2
Overheads | 6 | Rent | 47276.48 | 2
Run Code Online (Sandbox Code Playgroud)
我正在使用下面的代码来获得下面的结果集:
select * from trialbalancegrouping
PIVOT (Sum(value)
for nominalgroupname in ([Sales],[Cost of Sales],[Labour Costs],[Overheads])) AS PVTtable
Run Code Online (Sandbox Code Playgroud)
- …