MySQL finding gaps in column with multiple ID
<p>I would like to find gaps in following table:</p>

<pre><code>create table sequence
(
   `Id` int,
   `Value` int not null,
   PRIMARY KEY (`Id`,`Value`)
);

insert into sequence
    ( `Id`, `Value` )
  values
    (10, 0 ),
    (10, 1 ),
    (10, 4 ),
    (10, 5 ),
    (10, 6 ),
    (10, 7 ),
    (11, 0 ),
    (11, 1 ),
    (11, 2 ),
    (11, 5 ),
    (11, 7 );
</code></pre>

<p>Expeced result is somthing like:</p>

<pre><code>10 | 2-3
11 | 3-4
11 | 6
</code></pre>

<p>or </p>

<pre><code>10 | 2
10 | 3
11 | 3
11 | 4
11 | 6
</code></pre>

<p>I know, that value of the colum 'Value' is between 0 and 7.</p>

<p>Is it possible to do it using MySQL?</p>

<p><strong>EDIT 1</strong></p>

<p>Based on answers I come with this: </p>

<pre><code>SELECT Tbl1.Id, 
       startseqno, 
       Min(B.Value) - 1 AS END 
FROM   (SELECT Id, 
               Value + 1 AS StartSeqNo 
        FROM   SEQUENCE AS A 
        WHERE  NOT EXISTS (SELECT * 
                           FROM   SEQUENCE AS B 
                           WHERE  B.Id = A.id 
                                  AND B.Value = A.Value + 1) 
               AND Value &lt; (SELECT Max(Value) 
                            FROM   SEQUENCE B 
                            WHERE  B.Id = A.Id)) AS Tbl1, 
       SEQUENCE AS B 
WHERE  B.Id = Tbl1.Id 
       AND B.Value &gt; Tbl1.startseqno 
</code></pre>

<p>But now I am getting just </p>

<pre><code>10 | 2 | 3
</code></pre>

<p>Please, does somebody know, how to fix it? </p>

<p><a href="http://sqlfiddle.com/#!9/a59c6/2" rel="nofollow">sqlfiddle</a></p>