Mysql Group Query Query Query A field in the first 40 pieces of data in each group cannot continuously exceed 8 blank records. Please be instructed by the Great God

  mysql, question

The data structure is as follows:
Here is grouping and querying the first 40 records, but the following conditions do not know how to start, the condition is that sk_id cannot have 8 consecutive records empty

Sql is not easy to implement! You can use php traversal filtering