Files
email-tracker/external/duckdb/test/sql/pivot/pivot_generated.test
2025-10-24 19:21:19 -05:00

29 lines
637 B
SQL

# name: test/sql/pivot/pivot_generated.test
# description: Test pivot over generated columns
# group: [pivot]
statement ok
PRAGMA enable_verification
statement ok
CREATE TABLE Product(DaysToManufacture int, StandardCost int GENERATED ALWAYS AS (DaysToManufacture * 5));
statement ok
INSERT INTO Product VALUES (0), (1), (2), (4);
query IIIIII
SELECT 'AverageCost' AS Cost_Sorted_By_Production_Days,
"0", "1", "2", "3", "4"
FROM
(
SELECT DaysToManufacture, StandardCost
FROM Product
) AS SourceTable
PIVOT
(
AVG(StandardCost)
FOR DaysToManufacture IN (0, 1, 2, 3, 4)
) AS PivotTable;
----
AverageCost 0.0 5.0 10.0 NULL 20.0