我有下表但不确定是否可以转动这个并保留所有标签.
RATIO RESULT SCORE GRADE
Current Ratio 1.294 60 Good
Gearing Ratio 0.3384 70 Good
Performance Ratio 0.0427 50 Satisfactory
TOTAL NULL 180 Good
Run Code Online (Sandbox Code Playgroud)
我承认在使用枢轴方面不是很好,所以经过几次尝试导致这个输出:
SELECT 'RESULT' AS 'Ratio'
,[Current Ratio] AS 'Current Ratio'
,[Gearing Ratio] AS 'Gearing Ratio'
,[Performance Ratio] AS 'Performance Ratio'
,[TOTAL] AS 'TOTAL'
FROM
(
SELECT RATIO, RESULT
FROM GRAND_TOTALS
) AS SREC
PIVOT
(
MAX(RESULT)
FOR RATIO IN ([Current Ratio],[Gearing Ratio], [Performance Ratio], [TOTAL])
) AS PVT
Run Code Online (Sandbox Code Playgroud)
这给出了结果:
Ratio Current Ratio Gearing Ratio Performance Ratio …Run Code Online (Sandbox Code Playgroud)