Reputation: 704
I must be missing an obvious thing since after hours of testing I seem to be blind
table 1 created with
CREATE table1
SELECT column1,column2,SUM(column3)
FROM table2
WHERE condition1
GROUP BY column1,column2
doesn't have the expected row count
So I wanted to check table2 with
SELECT COUNT(DISTINCT column1,column2) FROM table2 WHERE condition1
and that gave me the expected row count
What is wrong in my way of proceeding ?
Upvotes: 0
Views: 145
Reputation: 1269753
The numbers would be different if either column1
or column2
were NULL
.
count(distinct)
does not count null
values. When used with multiple arguments, this is true even when only one expression is null
.
However, null
values go on separate rows in a group by
.
Upvotes: 1