表格tbltest
中的数据如下所示
+---------------+--------------+
| customfieldid | fieldvalue |
+---------------+--------------+
| 1 | 3 |
| 1 | 7 |
| 3 | 5 |
| 3 | 1 |
| 4 | 5 |
+---------------+--------------+
我想要customfieldid
fieldvalue asc
顺序从此表和分组中选择数据
答案 0 :(得分:0)
如果您希望按组分列第一个订单: -
Select * From
(SELECT customerfieldid, fieldvalue FROM tbltest
ORDER BY fieldvalue ASC ) new
GROUP BY new.customefieldid
或者如果您想按顺序排列第一组: -
SELECT `customerfieldid`, `fieldvalue`
FROM `tbltest`
GROUP BY `customfieldid`
ORDER BY `fieldvalue` ASC