要一直走下去

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

select t1.* from coal_installed_capacity t1
where NOT EXISTS
(select * from coal_installed_capacity t2 where t2.company_name = t1.company_name
and left(t2.data_time,6)=left(t1.data_time,6) and t2.data_time>t1.data_time
)

 

按照company_name , left(data_time,6) 分组, 按data_time排序,取排序第一条

posted on 2021-08-31 14:00  要一直走下去  阅读(2273)  评论(0编辑  收藏  举报