K
Kirk P.
Tom Ellison posted a solution to this issue back in April '06. I'm trying to
modify it slightly to fit my needs. I've got a large table with 2 fields:
entity and entry_no. The combination of entity and entry_no describe a
unique record, and I'm looking for gaps in the entry_no sequence WITHIN
entity. I'm throwing in GROUP BY clauses in various places, but so far I
haven't gotten it to work.
Here's what I've got thus far:
SELECT entry_no+1 AS BeginMissing, (SELECT MIN(entry_no)
FROM tblSEQUENCE T1
WHERE T1.entry_no > t.entry_no)-1 AS EndMissing
FROM tblSEQUENCE AS t
WHERE (((Exists (SELECT * FROM tblSEQUENCE T1
WHERE T1.entry_no = t.entry_no + 1))=False) AND ((t.entry_no)<(SELECT
Max(entry_no) FROM tblSEQUENCE)));
This works across all entry_no's, but not for entry_no's within entity
groupings. Help!
modify it slightly to fit my needs. I've got a large table with 2 fields:
entity and entry_no. The combination of entity and entry_no describe a
unique record, and I'm looking for gaps in the entry_no sequence WITHIN
entity. I'm throwing in GROUP BY clauses in various places, but so far I
haven't gotten it to work.
Here's what I've got thus far:
SELECT entry_no+1 AS BeginMissing, (SELECT MIN(entry_no)
FROM tblSEQUENCE T1
WHERE T1.entry_no > t.entry_no)-1 AS EndMissing
FROM tblSEQUENCE AS t
WHERE (((Exists (SELECT * FROM tblSEQUENCE T1
WHERE T1.entry_no = t.entry_no + 1))=False) AND ((t.entry_no)<(SELECT
Max(entry_no) FROM tblSEQUENCE)));
This works across all entry_no's, but not for entry_no's within entity
groupings. Help!