* 加上or null后,count统计数据的时候就会排出非2006/2008之外的数据,如果不加or null,则count会默认计数,等同于count(*)了。
2018-01-11
mysql> select count(year='2006' or null) as '2006' ,count(year='2009' or null) as '2008' from y;
+------+------+
| 2006 | 2008 |
+------+------+
| 2 | 1 |
+------+------+
1 row in set (0.00 sec)
+------+------+
| 2006 | 2008 |
+------+------+
| 2 | 1 |
+------+------+
1 row in set (0.00 sec)
2018-01-11