我只是想了解mysql
mysql> SELECT species, sex, COUNT(*) FROM pet
-> WHERE species = 'dog' OR species = 'cat'
-> GROUP BY species, sex;
+---------+------+----------+
| species | sex | COUNT(*) |
+---------+------+----------+
| cat | f | 1 |
| cat | m | 1 |
| dog | f | 1 |
| dog | m | 2 |
+---------+------+----------+
有可能得到吗?
+---------+-----------+-------------+
| species | malecount | femalecount |
+---------+-----------+-------------+
| cat | 1 | 1 |
| dog | 1 | 2 |
+---------+-----------+-------------+
在单个查询中?