mysql - sql query comparing values -
it's sql question found when i'm preparing interview.
how can efficiently find records value bigger previous one's?
id 1 2 3 4 5 value 6 5 10 8 30
you use self join this. long question compare current record previous record (and not previous records).
select t1.* table t1 inner join table t2 on t1.id = t2.id + 1 t1.value > t2.value
Comments
Post a Comment