この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 で、最高の行のみを選択したいと思います。
これどうやってするの?