结构和查询如下:http://www.sqlfiddle.com/#!9/de7ec8/4
这是结果:
+-------------+--------+
| id_requests | status |
+-------------+--------+
| 1 | 0 |
| 1 | 0 |
| 1 | 1 |
| 2 | 1 |
+-------------+--------+
4 rows in set
我正在寻找结果:
+-------------+--------+
| id_requests | status |
+-------------+--------+
| 1 | 0 |
| 1 | 1 |
| 2 | 1 |
+-------------+--------+
3 rows in set
我想按状态分组,但是对于每个id_requests,我们将不胜感激。
答案 0 :(得分:2)
您似乎正在为此使用distingle子句选择不同的行
SELECT distinct a.id_requests, b.status
FROM `admin_availability_requests` a