oracle怎么同时使用group by 和 order by

2024-12-04 19:33:33
推荐回答(2个)
回答1:

如果time是date型,直接group by max取出来即可
select a.id, a.status, a.time
from A, (select status, max(time) time from A group by A.status) B
where A.status = B.status
and A.time = B.time;

回答2:

order by 总是放在sql语句的最后。你这个直接对time字段进行order by 就可以了呀。降序排列。