Re: find missing numbers



Dear MH:

Use a subquery:

SELECT CLng(YourColumn) + 1 AS Missing
FROM YourTable T
WHERE NOT EXISTS(
SELECT *
FROM SomeTable T1
WHERE CLng(T1.YourColumn) = CLng(T.YourColumn) + 1)

This will report the first missing number of each sequence. You can add a
similar subquery to find the high end of each missing sequence. Finally,
you would probably want to omit the sequence starting ath the MAX() value of
this column which has not upper limit.

For a complete query in my response, provide your table name and column
name.

Note that it is probably a bad practice to store values that are numeric in
a text column. It makes work like this extra difficult, and cannot be
indexed to obtain decent performance. This is going to be horribly slow
given any large set of data. If the column were numeric and indexed, it
wouldn't be bad.

Tom Ellison


"mhmaid" <mhmaid@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DE92BEAD-46AE-477C-B0F5-79759EA3A6AE@xxxxxxxxxxxxxxxx
Is it possible for access to find missing numbers
ie. i have cpv numbers 1 2 3 4 etc I need to know if there is any missing
number in the sequence. this is not autonumber , it is a text field.
1 2 3 6 ( number 5 is missing )

i want a Query to display missing numbers , or , to tell that there is
break
in the sequence so and so.( out of sequence)


.



Relevant Pages

  • RE: Find missing Working Days
    ... contains one field (intNumbers) and the values of 0 through 9. ... I then create a query that generates numbers from zero through ... Can anyone think of a query that can check if any days are missing? ... results into a table if a number from 1 to 5 is out of sequence but I wonder ...
    (microsoft.public.access.queries)
  • Re: Programmers unpaid overtime.
    ... "A polynomial is a mathematical expression involving ... And if terms are missing, or the exponents are out of sequence, the ... You all think I'm paranoid, ...
    (comp.programming)
  • Re: puzzle
    ... Determine the xor of the numbers 0...n, ... >) sequence. ... Determine the sum of the numbers 0...n, ... The difference of the two sums is the missing number. ...
    (comp.programming)
  • Re: Query to find amissing number
    ... Here I need to write a query to find out that number 7 is missing in the ... given sequence. ... giving you a quick way to determine if any gaps exist. ...
    (comp.databases.sybase)
  • Re: finds gaps in sequential numbers?
    ... I too am looking for a way to determine missing numbers in a sequence. ... "Tom Ellison" wrote: ... This allows the query to look at the ...
    (microsoft.public.access.queries)