You need a column to represent the order you want to apply. Let's say there is a column id
in your table we can use for this. Such a column is usually not guaranteed to be consecutive (i.e. without gaps).
The easiest way to find the rows where the value is not greater than the previous value is to use LAG
which should be available in most modern DBMS. (For MySQL LAG
is available as of version 8).
select *
from
(
select t.*, lag(value) over (order by id) as previous_value from mytable t
) x
where value <= previous_value
order by id;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…