我有这个 MySQL 查询:
SELECT
SUM(scpe.scpe_estemated_days) AS total_days,
scp.cpl_startdate
FROM
studentcourseplanelements scpe
INNER JOIN
studentcourseplan scp ON scp.cpl_id = scpe.scpe_cpl_id
INNER JOIN
(SELECT
sd1.student_id, sd1.student_startdate
FROM
studentdates sd1
WHERE
sd1.student_id = '360'
LIMIT 1) sd ON sd.student_id = scp.student_id
GROUP BY scp.cpl_id
这输出:
+------------+---------------+
| total_days | cpl_startdate |
+------------+---------------+
| 5 | 2012-11-01 |
| 129 | 2012-11-02 |
+------------+---------------+
我只想选择最高的行total_days
,在我的示例中为 129。
我怎样才能做到这一点?