Select all before first break 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?
This will work for the special case:

SELECT *
FROM your_table 
WHERE sort &lt; (SELECT MIN(t.sort) 
              FROM your_table AS t
              LEFT JOIN your_table AS t2
                  ON t.sort = t2.sort+1 
              WHERE t2.sort IS NULL
                AND t.sort &gt; (SELECT MIN(sort) FROM your_table))