Q: MYSQL: Encontrar subsequencias numa sequencia e agrupar por ID Tenho uma tabela com o seguinte resultado:
------------------
|seq  |   ID     |
------------------
| 1   |  12345   |
| 2   |  12345   |
| 3   |  12345   |
| 4   |  12345   |
| 8   |  12345   |
| 9   |  54321   |
| 10  |  54321   |
| 11  |  54321   |
| 12  |  54321   |
| 13  |  54321   |
| 14  |  12345   |
| 15  |  12345   |
------------------

E neste momento estou a utilizar a seguinte query:
SELECT min(cardinals.seq) as start, max(cardinals.seq) as stop, r.PART_NUMBER --tao em uso no codigo
  FROM (
        SELECT A.N + 5*(B.N + 5*(C.N + 5*(D.N + 5*(E.N + 5*(F.N))))) AS seq  
          FROM (SELECT 0 AS N UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS A
          JOIN (SELECT 0 AS N UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS B
         JOIN (SELECT 0 AS N UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS C
         JOIN (SELECT 0 AS N UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS D
         JOIN (SELECT 0 AS N UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS E
         JOIN (SELECT 0 AS N UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS F
           ) cardinals
  JOIN (
             SELECT PART_NUMBER, MIN(SERIAL_NUMBER) as minSeq, MAX(SERIAL_NUMBER) as maxSeq
               FROM  manifa6_import_manif
               where wu_name='FT4WU9C7'  
              GROUP BY PART_NUMBER
       ) r ON cardinals.seq >= r.minSeq AND cardinals.seq <= r.maxSeq
  LEFT JOIN  manifa6_import_manif ON cardinals.seq =  manifa6_import_manif.SERIAL_NUMBER AND r.PART_NUMBER = manifa6_import_manif.part_number
 WHERE  manifa6_import_manif.SERIAL_NUMBER IS NULL

O resultado desta query é NULL
E preciso que me dê o seguinte resultado:
 -------------------------
 |start  | Stop   | ID   |
 -------------------------
 |  1    |  4     |12345 |
 |  8    |  8     |54321 |
 |  9    |  13    |54321 |
 |  14   |  15    |12345 |
 -------------------------

Conseguem me ajudar?
Obrigado

A: Segue a baixo o SQL DDL de trabalho:

    CREATE DATABASE stackoverflow;

CREATE TABLE `manifa6_import_manif` (
  `seq` int(11) NOT NULL AUTO_INCREMENT,
  `ID` int(11) DEFAULT NULL,
  `PART_NUMBER` varchar(45) DEFAULT NULL,
  `SERIAL_NUMBER` int(11) DEFAULT NULL,
  `wu_name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`seq`)
);

 
E como resposta, segue a baixo o SQL DML:

INSERT INTO `manifa6_import_manif` (`seq`,`ID`,`PART_NUMBER`,`SERIAL_NUMBER`,`wu_name`) 
VALUES  (1,12345,'333',1,NULL),
        (2,12345,'333',2,'FT4WU9C7'),
        (3,12345,'333',3,NULL),
        (4,12345,'333',4,NULL),
        (8,54321,'444',8,'FT4WU9C7'),
        (9,54321,'555',9,'FT4WU9C7'),
        (10,54321,'555',10,NULL),
        (11,54321,'555',11,NULL),
        (12,54321,'555',12,NULL),
        (13,54321,'555',13,'FT4WU9C7'),
        (14,12345,'666',14,'FT4WU9C7'),
        (15,12345,'666',15,NULL);


SELECT 
    MIN(mim1.SERIAL_NUMBER) as `start`, 
    MAX(mim1.SERIAL_NUMBER) as `Stop`,
    mim1.ID
FROM  manifa6_import_manif mim1
-- where wu_name='FT4WU9C7'  
GROUP BY mim1.PART_NUMBER;


NOTA: @Gomez, tive que inferir, e tive que popular o campo `manifa6_import_manif`.`PART_NUMBER` com dados que possibilitasse o agrupamento conforme a cláusula GROUP BY PART_NUMBER. Espero que na aplicação seja possível usar a consulta como solução.
Pessoal, para perguntas de Banco de Dados seria de grande ajuda colocar a SQL DDL de criação das possíveis tabelas de trabalho.

Referência:
[Paul Dubois at al, 2005], MySQL® 5.0: Certification Study Guide
