Take the 2-minute tour ×  Having a table with the following
fields:   it is required that all orders in a given group form a
continuous sequence. For example: 1,2,3,4 or 4,5,6,7. How can I
check using a single SQL query what orders do not comply with
this rule? Thank you.  Example data:  Order   Group   Sequence 1
1   3 2   1   4 3   1   5 4   1   6 5   2   3 6   2   4 7   2
6  Expected result:  Also accepted if the query returns only the
group which has the wrong sequence, 2 for the example data.
share|improve this question which sql db are you using. in
oracle its possible you could do this with the ranking functions
... –  Sam Saffron May 18 '09 at 9:20 Microsoft Access :) – 
Tihauan May 18 '09 at 9:25 The answers disagree Which column
contains the 1,2,3,4 data, maybe you can clarify with some
examples. –  Andomar May 18 '09 at 9:37 add comment  6 Answers
up vote 4 down vote accepted  Assuming that the sequences are
generated and therefore cannot be duplicated:  SELECT group
FROM theTable  GROUP BY group  HAVING MA