View previous topic :: View next topic |
Author |
Message |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Tue Mar 30, 2010 6:53 am Post subject: identifying gap in 'sequence' in column ? |
|
|
I have a table with 2 columns... POLNO is the 'key' column. Would there
be a way to identify the POLNOs where there is a 'gap' in the sequencing
of ITEMNOs ?... e.g., could I identify POLNO BBB in the example below as having a 'gap' ? (maximum value of ITEMNO is 6 if that makes a difference)
Thanks for any help.
Code: | POLNO ITEMNO
AAA 1
AAA 2
AAA 3
BBB 1
BBB 2
BBB 4
CCC 1
CCC 2
CCC 3
CCC 4 |
|
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Tue Mar 30, 2010 10:36 am Post subject: |
|
|
Didn't test it but this is my thought -
Code: | SELECT POLNO
FROM TABLENAME
GROUP BY POLNO
HAVING COUNT(*) < (MAX(ITEMNO) - MIN(ITEMNO) + 1) |
|
|
Back to top |
|
|
|
|