D WITH suppliers AS (
SELECT *
FROM (VALUES (1, 10.0), (1, 20.0)) AS t(nation, acctbal)
)
SELECT
ROW_NUMBER() OVER (PARTITION BY nation ORDER BY acctbal DESC) AS rn
FROM suppliers AS s
WHERE acctbal > (
SELECT AVG(acctbal) FROM suppliers
);
┌───────┐
│ rn │
│ int64 │
├───────┤
│ 1 │
└───────┘
> WITH suppliers AS (
SELECT *
FROM (VALUES (1, 10.0), (1, 20.0)) AS t(nation, acctbal)
)
SELECT
ROW_NUMBER() OVER (PARTITION BY nation ORDER BY acctbal DESC) AS rn
FROM suppliers AS s
WHERE acctbal > (
SELECT AVG(acctbal) FROM suppliers
);
Optimizer rule 'common_sub_expression_eliminate' failed
caused by
Error during planning: Window has mismatch between number of expressions (1) and number of fields in schema (0)