raziel3
Registered User.
- Local time
- Today, 15:43
- Joined
- Oct 5, 2017
- Messages
- 316
Hello all,
I am trying to make a query to get numbers missing in a sequence. So far I've used this
The results:
Unfiltering the "MISSING" field gives me this:
As you can see numbers 503, 504, 505 are undetected by the query. My intention is to create a temporary table from CHQREGISTER listing all the numbers in sequence to the MAX CHQNUM then join CHQREGISTER to it.
How would I go about creating that temporary table?
I am trying to make a query to get numbers missing in a sequence. So far I've used this
Code:
SELECT CHQREGISTER.CHQNUM, (SELECT TOP 1 T1.CHQNUM
FROM CHQREGISTER AS T1
WHERE T1.CHQNUM = CHQREGISTER.CHQNUM+1
ORDER BY T1.CHQNUM ASC) AS SEQ, IIf(IsNull([SEQ]),[CHQNUM]+1,"") AS MISSING
FROM CHQREGISTER
WHERE ((((SELECT TOP 1 T1.CHQNUM
FROM CHQREGISTER AS T1
WHERE T1.CHQNUM = CHQREGISTER.CHQNUM+1
ORDER BY T1.CHQNUM ASC)) Is Null))
ORDER BY CHQREGISTER.CHQNUM;
The results:
Unfiltering the "MISSING" field gives me this:
As you can see numbers 503, 504, 505 are undetected by the query. My intention is to create a temporary table from CHQREGISTER listing all the numbers in sequence to the MAX CHQNUM then join CHQREGISTER to it.
How would I go about creating that temporary table?