SQL

select d.* from (select c.* ,rownum row_id from (select b.* from
(select a.* ,row_number() over(partition by a.orderId order by a.stateTime desc) rn
from
(select
r.order_id orderId,
ro.CUSTOMER customer,
ro.submit_time submitTime,
r.order_state orderState,
r.state_time stateTime
from
reds_staus r
left join
reds_order ro
on
r.order_id = ro.order_id ) a) b
where b.rn = 1 order by b.stateTime desc ) c) d where
d.row_id between 0 and 100

你可能感兴趣的:(sql)