Re: Finding available customer numbers
From: Anith Sen (anith_at_bizdatasolutions.com)
Date: 06/02/04
- Previous message: Dan: "Re: Currency Format with Comma Delimination"
- In reply to: Mac: "Re: Finding available customer numbers"
- Next in thread: mac: "Re: Finding available customer numbers"
- Reply: mac: "Re: Finding available customer numbers"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 2 Jun 2004 11:11:41 -0500
This will give you all the gaps :
SELECT col + 1
FROM tbl
WHERE NOT EXISTS( SELECT * FROM tbl t1
WHERE t1.col = tbl.col + 1 )
AND IDNo < ( SELECT MAX( col ) FROM tbl );
To get the smallest one:
SELECT MIN( col ) + 1
FROM tbl
WHERE NOT EXISTS( SELECT * FROM tbl t1
WHERE t1.col = tbl.col + 1 ) ;
-- Anith
- Previous message: Dan: "Re: Currency Format with Comma Delimination"
- In reply to: Mac: "Re: Finding available customer numbers"
- Next in thread: mac: "Re: Finding available customer numbers"
- Reply: mac: "Re: Finding available customer numbers"
- Messages sorted by: [ date ] [ thread ]