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

oracle:查询各组最新的一条数据(按照某个条件)

程序员文章站 2024-03-19 23:15:04
...

oracle:查询各组最新的一条数据(按照某个条件)

 

select sp.shenpi_duixiang,sp.jiaohu_yijian from shenpi_yijian sp inner join(
    SELECT shenpi_duixiang,MAX(chuangjian_shijian) as cttime FROM shenpi_yijian s group by shenpi_duixiang
    having shenpi_duixiang in ('937612','827255','883559','982301','959838','844040','866898','828975','866981','855758','937266','882652','879265','982312',
    '937424','890664','854159','982728','860616','959679','954795','912913','839046','937422','949665','937193','860611','949518','866881','843973')) B
     on sp.shenpi_duixiang = b.shenpi_duixiang and sp.chuangjian_shijian = b.cttime

原文转载:https://blog.csdn.net/ShelleyLittlehero/article/details/85041768