sql语句 根据条件分组 怎么写呢?
发布网友
发布时间:2022-04-11 03:37
我来回答
共2个回答
热心网友
时间:2022-04-11 05:07
是筛选出bookid的datetime最新的记录吗?
oracle 可用
select orderid,bookid,datetime from (
select orderid,bookid,datetime, row_number() over(partition by bookid order by datetime desc) "row" ) where "row"=1
热心网友
时间:2022-04-11 06:25
select * from table a where exists
(select 1 from table where booksid=a.booksid
group by booksid
having max(datetime)=a.datetime)