3,491
社区成员
发帖
与我相关
我的任务
分享
with table1 as (
select '01' c_id, '2008-03-17' d_date, 0 n_num from dual union all
select '02' c_id, '2008-03-18' d_date, 1 n_num from dual union all
select '03' c_id, '2008-03-19' d_date, 2 n_num from dual union all
select '04' c_id, '2008-03-20' d_date, 3 n_num from dual union all
select '05' c_id, '2008-03-21' d_date, 4 n_num from dual union all
select '06' c_id, '2008-03-22' d_date, 3 n_num from dual union all
select '07' c_id, '2008-03-23' d_date, 5 n_num from dual union all
select '08' c_id, '2008-03-24' d_date, 4 n_num from dual union all
select '09' c_id, '2008-03-25' d_date, 10 n_num from dual union all
select '10' c_id, '2008-03-26' d_date, 8 n_num from dual union all
select '11' c_id, '2008-03-27' d_date, 9 n_num from dual union all
select '12' c_id, '2008-03-28' d_date, 10 n_num from dual union all
select '13' c_id, '2008-03-29' d_date, 11 n_num from dual union all
select '14' c_id, '2008-03-30' d_date, 6 n_num from dual
)
select * from table1 a where n_num<(select max(n_num) n_num from table1 b where b.c_id<a.c_id)
select c_id,d_date,n_num from (
select t.*,max(n_num) over(order by t.d_date) ld from table_name t order by t.d_date
) where n_num >= ld