How can we reproduce it (as minimally and precisely as possible)?
WITH
Store AS (
SELECT 20 AS sold, "apples" AS fruit
UNION ALL
SELECT 10 AS sold, "apples" AS fruit
UNION ALL
SELECT 40 AS sold, "pears" AS fruit
UNION ALL
SELECT 10 AS sold, "oranges" AS fruit
UNION ALL
SELECT 30 AS sold, "bananas" AS fruit
UNION ALL
SELECT 10 AS sold, "bananas" AS fruit
)
SELECT
ANY_VALUE(x HAVING MIN sold) AS least_sales,
ANY_VALUE(x HAVING MAX sold) AS most_sales
FROM Store x
GROUP BY fruit
Anything else we need to know?
At face value, it looks like it just takes the first row.
What happened?
As per title (see below for more info)
What did you expect to happen?
I expected the query below to return:
Instead, it incorrectly returns (note
apples
andbananas
:How can we reproduce it (as minimally and precisely as possible)?
Anything else we need to know?
At face value, it looks like it just takes the first row.