The minimum missing page_number value is easy:
SELECT MIN(RECNO()) AS MinMissing ;
FROM YourTable ;
WHERE page_number <> RECNO()
The maximum missing page_number is more complex and requires VFP9:
SELECT MIN(page_number)-1 AS MaxMissing ;
FROM YourTable ;
WHERE page_number - RECNO() = (SELECT MAX(page_number-RECNO()) FROM YourTable)
In earlier VFP versions you have to calculate subquery separately.
And because the table can contain deleted records and SET DELETED can be ON the best solution is classic xBase code (suppose page_number values are unique and growing when no order is set):
Main Topics
Browse All Topics





by: JF0Posted on 2009-10-15 at 16:16:51ID: 25585790
Do you require a SQL query only solution? This is just an example, but it will place the missing numbers in a new field called "missing" and assumes both the "numbers" field and "missing" fields are character. You can then query this "missing" field.
GO top
ilast = 0
SCAN all
icurrent = VAL(numbers)
IF icurrent != ilast + 1
replace missing WITH ALLTRIM(STR(RECNO()))
ilast = VAL(missing)
ELSE
ilast = icurrent
ENDIF
ENDSCAN