tableABC有单独的日期和时间列:
+-----------+--------+-----------+-----------+
| AccountID | userID | date | timestamp |
+-----------+--------+-----------+-----------+
| 123 | 1 | 29-MAR-13 | 21005 |
| 123 | 1 | 29-MAR-13 | 11005 |
| 123 | 1 | 23-MAR-13 | 21005 |
+-----------+--------+-----------+-----------+
我需要日期列和时间戳列的最大值。我写的查询只做日期的最大值而不是时间戳:
select *
from tableABC rn
where userID = '1'
and accountID = '123'
and date =
(
select max(date) MaxDate
from tableABC b
where b.userID = rn.userID
and b.accountID = rn.accountID
);