Wie kann man in MySQL null und nicht null in derselben Spalte zählen und abrufen?
mein Tisch
---------------------------------------------------
id | name | visited | registDate |
---------------------------------------------------
1 | george | NULL | 2014-04-01 |
---------------------------------------------------
2 | Thomas | NULL | 2014-04-15 |
---------------------------------------------------
3 | Wilfred | 1 | 2014-04-24 |
---------------------------------------------------
4 | paul | 1 | 2014-04-10 |
---------------------------------------------------
5 | elina | NULL | 2014-05-03 |
---------------------------------------------------
6 | angela | NULL | 2014-04-13 |
---------------------------------------------------
7 | elina | 1 | 2014-05-18 |
---------------------------------------------------
Erwartetes Ergebnis
month register visited not visited
---------------------------------------------
05-2014 2 1 1
---------------------------------------------
04-2014 5 2 3
---------------------------------------------
count(visited)
. count (<column>) zählt nur nicht null. Wenn Sie eine weitere Verschachtelungsebene hinzufügen, kann count_not_visited alscount_registered - count_visited