I have MySql 5.7 and a table "FizzBuzz"
ID | Name | Sort |
---|---|---|
1 | Foo | 1 |
2 | Bar | 2 |
3 | Baz | 5 |
4 | Quux | 6 |
5 | Xyzzy | 7 |
6 | Plugh | 9 |
I need to get the records that follow each other in the sort field before the first increment break.
For example,
SELECT Name
FROM FizzBuzz
WHERE sort >= 1 and /* some */
should return only: Foo and Bar
And
SELECT Name
FROM FizzBuzz
WHERE sort > 2 and /* some */
should return only: Baz, Quux and Xyzzy
How can this be done?