Hallo Dukel,
danke für die schnelle Antwort. Aber ich verstehe das nicht ganz:
-- Pivot table with one row and five columns
SELECT 'AverageCost' AS Cost_Sorted_By_Production_Days,
[0], [1], [2], [3], [4]
FROM
(SELECT DaysToManufacture, StandardCost
FROM Production.Product) AS SourceTable
PIVOT
(
AVG(StandardCost)
FOR DaysToManufacture IN ([0], [1], [2], [3], [4]) )
AS PivotTable;
Das Beispiel ist kalr, aber ich weiß nicht die genaue Anzahl der Spalten. Diese variieren je nach Ergebnis der Query.
Ich habe mal das Ergebnis als Bild angehängt. Die Spalter strName und strWert sollen gedreht ausgegeben werden, da diese als Grundlage für einen Report sind.
Mfg Torsten