select - SQL query to find row with no immediate successor -
i have sql query returns me next result:
select id, position (...) aaa 6 aab 5 aac 3 aad 2 so need first row no immediate successor. here illustration:
first row6 next 5 has successor 6 -> 5 second row 5 next 3 has no successor, because 4 missing so in illustration outer select should homecoming aab 5
here's query believe asking. joins table on position - 1. ones null.
select a.* test1 left bring together test1 b on a.position - 1 = b.position b.position null this returns
aab 5 aad 2 sql select order
No comments:
Post a Comment