MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

identifying gap in 'sequence' in column ?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Tue Mar 30, 2010 6:53 am    Post subject: identifying gap in 'sequence' in column ? Reply with quote

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
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Tue Mar 30, 2010 10:36 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group