これは私が今私のクエリに持っているものです:
+--------------------+-----------+------------+
| status | entity_id | seconds |
+--------------------+-----------+------------+
| Submitted | 494 | 1352102400 |
| Accepted | 494 | 1352275200 |
| In press/e-publish | 494 | 1352966400 |
| Rejected | 520 | 1355817600 |
| Accepted | 570 | 1352102400 |
+--------------------+-----------+------------+
私はそれが次のようになりたい:
+--------------------+-----------+------------+
| status | entity_id | seconds |
+--------------------+-----------+------------+
| In press/e-publish | 494 | 1352966400 |
| Rejected | 520 | 1355817600 |
| Accepted | 570 | 1352102400 |
+--------------------+-----------+------------+
準 SQL の場合:
SELECT status, entity_id, MAX(seconds)
FROM foo
GROUP BY entity_id, seconds
上記の準 SQL は正しいように見えますが、「ステータス」列の値が正しい行に対応していません。以下のようなものが返ってきます。
+--------------------+-----------+------------+
| status | entity_id | seconds |
+--------------------+-----------+------------+
| Submitted | 494 | 1352966400 |
| Rejected | 520 | 1355817600 |
| Accepted | 570 | 1352102400 |
+--------------------+-----------+------------+