2 ms·
Here’s a Redshift oddity that I don’t think is documented: select sum(y.a), count(y.a) from(select distinct x.a from ( select 1 as a union all select 2 as a u
by gigatexal 6y ago
Here’s a Redshift oddity that I don’t think is documented:
select sum(y.a), count(y.a) from(select distinct x.a from ( select 1 as a union all select 2 as a union all select 1 as a)x)y
sum | count
-----+-------
4 | 3
Sqlite3 returns the correct results of sum of 3 count of 2.
To fix this don’t use subqueries.
- hans_castorp 6y agoInteresting, Postgres does this correctly: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=dc4ce40bd526955b38db4bc96cb781c2 https://dbfiddle.uk/?rdbms=postgres_12&fiddle=dc4ce40bd52695...