I have a table with three columns: id, sort, name in PostgreSQL 9.5 database.
I need to select all rows starting from sort=1 and before the first break (ordered by sort).
For example I have:
id | sort | name
1 | 1 | 'ss'
2 | 2 | 'ss'
3 | 3 | 'ss'
4 | 4 | 'ss'
5 | 7 | 'ss'
6 | 8 | 'ss'
I want to select rows with id=1,2,3,4.
As you can see, there is a break in the sort sequence (4-7). So I only need the rows before this break.
How can I do this?