Ich habe die folgende Tabelle, aber nicht sicher, ob es möglich ist, dies zu schwenken und alle Etiketten zu behalten.TSQL PIVOT MULTIPLE COLUMNS
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
ich nicht sehr gut zu sein bei der Verwendung von schwenkt zugeben wird, so dass nach mehreren Versuchen in dieser Ausgabe führt:
IRatio Current Ratio Gearing Ratio Performance Ratio
Result 1.294 0.3384 0.0427
:
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
Dies ist das Ergebnis gibt Ich gebe zu, dass ich sehr verwirrt darüber bin, was ich als Nächstes tun muss, um das Ergebnis zu erzeugen, das ich brauche:
Ratio Current Ratio Gearing Ratio Performance Ratio TOTAL
Result 1.294 0.3384 0.0427 NULL
Score 60 70 50 180
Grade Good Good Satisfactory Good
Welche Version von SQL Server verwenden Sie? – Taryn
mögliche Duplikate von [Mehrere Spalten Pivot in T-SQL] (http://stackoverflow.com/questions/947281/multiple-column-pivot-in-t-sql) –