sql - COUNT() doesn't work with GROUP BY? -


select count(*) table group column 

i total number of rows table, not number of rows after group by. why?

because how group by works. returns 1 row each identified group of rows in source data. in case, give count each of groups.

to want:

select count(distinct column) table; 

edit:

as slight note, if column can null, real equivalent is:

select (count(distinct column) +         max(case when column null 1 else 0 end)        ) table; 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -