Tom said:
Please can someone tell me how to identify gaps in supposedly sequential data
and calculate the value of teh difference. Thanks.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I found this solution on an SQL Server forum (translated to JET SQL):
SELECT last_nbr
, next_nbr
, last_nbr + 1 As first_avail
, next_nbr - 1 As last_avail
, next_nbr - (last_nbr + 1) As total_nbrs
FROM (SELECT
(SELECT NZ(Max(Seq2.SeqNumber),0) As SeqNumber
FROM SequenceTable Seq2
WHERE Seq2.SeqNumber < Seq1.SeqNumber) As last_nbr
, SeqNumber As next_nbr
FROM SequenceTable Seq1) as A
WHERE next_nbr - last_nbr > 1
ORDER BY last_nbr
Output example:
last_nbr next_nbr first_avail last_avail total_nbrs
0 10 1 9 9
103 105 104 104 1
107 114 108 113 6
116 129 117 128 12
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBSlZQnoechKqOuFEgEQIy0QCgjkq8fUZbxVef3n1LgulrjWYbPQYAoK5L
Ol9OsAFUps4yyDB+PQL/J+iK
=jhwq
-----END PGP SIGNATURE-----