按 gpcode每组 取每组 f4 最大的那条记录: 

方法一:

select * from calcgsdataflash a where gscode = 'LS_F' and ymd >= 20171117 and ymd <= 20171117

and 1 >= (select count(*) from calcgsdataflash b where gscode = 'LS_F' and ymd >= 20171117 and ymd <= 20171117

and a.gpcode = b.gpcode and a.f4 <= b.f4);

前 N 条 就是 N >=

 

方法二:

SELECT * FROM (SELECT * FROM calcgsdataflash where gscode = 'LS_F' and ymd >= 20171117 and ymd <= 20171117) a ,

(SELECT gpcode ,MAX(f4) as f4 FROM calcgsdataflash where gscode = 'LS_F' and ymd >= 20171117 and ymd <= 20171117 GROUP BY gpcode) b

where a.gpcode = b.gpcode AND a.f4 = b.f4;

  

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2022-01-01
  • 2021-11-18
  • 2021-11-18
猜你喜欢
  • 2022-01-08
  • 2021-08-27
  • 2022-01-01
  • 2022-01-01
  • 2022-01-01
  • 2022-01-05
  • 2021-10-14
相关资源
相似解决方案