The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question, kamrul hasan.
Asked: May 25, 2017 - 12:06 pm UTC
Last updated: May 25, 2017 - 2:33 pm UTC
Version: Oracle 11g
Viewed 1000+ times
with rws as ( select 1 id, date'2015-01-01' dt from dual union all select 2 id, date'2017-01-01' dt from dual union all select 3 id, date'2016-01-01' dt from dual union all select 4 id, date'2018-01-01' dt from dual ), prev as ( select r.*, lag(dt) over (order by id) prev_dt from rws r ) select * from prev where dt < prev_dt; ID DT PREV_DT 3 01-JAN-2016 00:00:00 01-JAN-2017 00:00:00
Analytic SQL got you confused? Check out Connor McDonald's complete video course.