Find Squence of #s

Topher

Registered User.
Local time
Today, 13:05
Joined
Apr 18, 2000
Messages
72
I also put this under the Query Forum, but i thought i would try a module as well.

Is it possible to write a query or code that can determine if a list of records are in sequential order?
ie 1,2,3,4

what i want to do is find out of say 1000 records if there is are some free sequential #s. the sequential #s are then given to some other records for processing. also the user selects how many sequential records they need - and they can also put in the # they want to start at - or just let the system find the sequence. i have to be able to look for the sequence because the user can also reserve #s they want or need. so that could leave #s in the middle that are not used yet.

i think i can figure it out using code to do it - but this might get awfully slow if it has to compare and look for or through a lot of #s

any help appreciated! =D

- T
 
I have done something similar recently and I think you're going to struggle to do this in a query, although I may be wrong. There were many more than 1000 records in my table and it worked very quickly and was doing a lot more than you seem to require.
 
thats good to hear - maybe it won't be slow after all - guess only way to find out is to try it.

can i ask how you determined the sequence? im thinking something like

get the 1st #
get the 2nd #
see what the difference is

if the difference is equal to or greater than the sequence the user wants then i can use the sequence starting at the 1st # + 1 to the 2nd # - 1

although with this approach i think i could be cycling through a lot of records until i find a difference that is equal to what the user wants..

- T
 
I was actually looking for 2 entries the same rather than a sequence but it works in the say way. I accomplished it by looking at the 1st the 2nd & comparing them, 2nd & 3rd and so on. With only 1000 records I think you'll be surprised at it's speed, then again maybe I'm easily pleased!
 

Users who are viewing this thread

Back
Top Bottom