select r1.a,r1.date from table_1 as r1 left join table_1 as r2 on r2.a=r1.a and r2.date >r1.date where r2.date is null
SQL DB2 找第二大日期 [解决办法] select * from table_1 order by date desc fetch first 3 rows only [解决办法] select * from tb A where 1=(select count(*) from tb B where A.日期<B.日期)
select * from tb A where 2=(select count(*) from tb B where A.日期<B.日期)
select * from tb A where 3=(select count(*) from tb B where A.日期<B.日期) [解决办法]
这个应该可以,取到的结果放在list里面,按下标取list中的元素即可。 [解决办法] select * from ( select * from table_1 order by date desc fetch first 2 rows only ) t order by date fetch first 1 rows only [解决办法] SELECT * FROM AA A1 WHERE 3>(SELECT COUNT(*) FROM AA WHERE A1.a=a AND A1.日期<=日期) [解决办法] row_number over 如 select ROW_NUMBER() OVER(PARTITION BY A列 ORDER BY 日期列) as sxh, a列,日期列 from a表 where sxh>=3 手边没db2 大概想了下 主要是就是这个olap函数的使用 比上面简单点了