How can I count existing and non-existing values with MySQL?
Posted
by
jaya malladi
on Stack Overflow
See other posts from Stack Overflow
or by jaya malladi
Published on 2012-11-15T06:11:00Z
Indexed on
2012/11/15
11:01 UTC
Read the original article
Hit count: 165
I am new to MySQL.
I have a table with answer ids.
Answers can look like this:a1, a2, a3 ...
, but due to some problems some are NULL
, some are blank, and some are others like 1 a
etc.
Now I want to calculate the count of ids with a1 a2 a3
distinctly. But how is it possible to do this leaving others like NULL
, blanks and garbage.
The output should look like this
atype count
a1 45
a2 0
a3 56
If there is no row entry for a particular answer, the count should be 0.
© Stack Overflow or respective owner