missing number in a sequence

M

Meg Brady

I'm trying to write a query that finds a missing number in a sequence, when I
don't know how many numbers are in the sequence. Anybody have any ideas?
 
K

KARL DEWEY

Type in your number in cell A1. Click on the cell (not in it). Move you
cursor to the lower right corner and when the shape changes from an open
cross to a solid cross, drag it down the worksheet. You will see it
incrementing as you drag it.
 
K

KARL DEWEY

One way is the use Excel auto fill to create a list of your numbers and place
in Access. Then create an Unmatched query between that table and your list.
 
J

John W. Vinson

On Thu, 8 Mar 2007 11:13:03 -0800, Meg Brady <Meg
I'm trying to write a query that finds a missing number in a sequence, when I
don't know how many numbers are in the sequence. Anybody have any ideas?

A Self Join will work:

SELECT A.numberfield+1 AS Missing
FROM yourtable AS A
LEFT JOIN yourtable AS B
ON B.numberfield = A.numberfield + 1
WHERE B.numberfield IS NULL;

This will show the first missing value in any block of missing values; of
course you'll always get at least one hit, the infinitely large gap after the
largest value in the table.

John W. Vinson [MVP]
 
M

Meg Brady

Great, thanks! Unfortunatly, I have next to no experience with Excel. Any
advice on how to do the auto fill?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top