欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

打开重复记录的所有字段值并获取离当前时间最近的记录

程序员文章站 2022-04-01 08:52:49
...
方法一:
select o.* from zjx_order o where o.ordertime = (select max(ordertime) from zjx_order  group by identitycard having o.identitycard = identitycard )

方法二:
select * from zjx_order where (identitycard,ordertime) in(select identitycard,max(ordertime) from zjx_order group by identitycard )