我想向网站添加调查。一个好的调查需要一份报告。一些基本的报告已经完成。现在我想在咖啡上加点奶油...
带有样本数据的表格:
mysql> select * from u001;
+----+----------+------------+-------+---------------------+
| id | drink | sex | age | date |
+----+----------+------------+-------+---------------------+
| 1 | Beer | m | 30-39 | 2012-10-17 23:17:52 |
| 2 | Milk | f | 10-19 | 2012-10-18 00:15:59 |
| 3 | Milk | f | 20-29 | 2012-10-18 23:33:07 |
| 4 | Tea | m | 30-39 | 2012-10-20 22:47:08 |
| 5 | Water | f | 20-29 | 2012-10-20 22:47:30 |
| 6 | Milk | m | 30-39 | 2012-10-20 22:51:22 |
+----+----------+------------+-------+---------------------+
6 rows in set (0.00 sec)
我想得到一个结果,计算有多少女性/男性喜欢茶/啤酒/等。想要的结果是这样的:
+-------+-----+---------+
| drink | sex | counted |
+-------+-----+---------+
| Beer | m | 1 |
| Milk | f | 2 |
| Tea | m | 1 |
| Water | f | 1 |
| Milk | m | 1 |
+-------+-----+---------+
有人有什么建议或解决方案吗?提前致谢。