BigQuery Absolutely puzzled with this Bigquery result
I have this query in Bigquery:
SELECT column1, column2, count(*)
FROM table
GROUP BY column1, column2
HAVING COUNT(*) >
1
When I run it, I get no data as a result, so no duplicates in the table.
However, if I run this
SELECT count(*)
FROM (
SELECT column1, column2, count(*)
FROM table
GROUP BY column1, column2
HAVING COUNT(*) >
1
)
The result is 470548, meaning every single row in the table. Why? I would expect to get 0 or null, since the subquery has no result at all.
12
Upvotes
View all comments
Show parent comment
1
u/agrvz Jun 02 '26
FYI that's not correct about COUNT DISTINCT. It used to be true for BigQuery legacy SQL but isn't for GoogleSQL.