Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select command to highlight missing Numbers
Message
From
22/04/2008 06:33:09
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01311939
Message ID:
01312316
Views:
15
>Hi.
>Is there any syntax of a Select command that will higghlight mssing numbers.
>I have a table which has a field which should be sequential and I want to highlight if there are any msiing numbers.
>I can do this by writing a program but wondered if there was a way to do this using select synatax ?
>Regards
>Gerard
CREATE CURSOR NUMBERS (FN I)
FOR K=1 TO 100
	INSERT INTO NUMBERS VALUES (RAND()*97+3)
NEXT
SELECT DISTINCT FN FROM NUMBERS INTO CURSOR NUMBERS

* RETURN GAPS
lowerBound = 1
UpperBound = 100
SELECT m.lowerBound	GapBegin;
,		MIN(FN)-1	GapEnd;
	FROM NUMBERS N;
	HAVING MIN(FN)>m.lowerBound;
UNION ALL;
SELECT	N.FN+1	;
	,	NVL((SELECT MIN(FN) FROM NUMBERS WHERE FN > N.FN ) - 1,m.UpperBound ) ;
	FROM NUMBERS N;
	WHERE NOT EXISTS(SELECT * FROM NUMBERS WHERE FN-1 = N.FN)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform