Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find skipped number
Message
De
12/08/2004 08:47:24
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00932576
Message ID:
00932639
Vues:
25
This is the solution for "Range skipped" with a single Query
CLEAR
#DEFINE RANGESTART 	  1
#DEFINE RANGEEND 	100

CREATE CURSOR TWITHHOLES (F1 INT NULL)

INSERT INTO TWITHHOLES VALUES (3)
INSERT INTO TWITHHOLES VALUES (4)
INSERT INTO TWITHHOLES VALUES (5)
INSERT INTO TWITHHOLES VALUES (8)
INSERT INTO TWITHHOLES VALUES (9)
INSERT INTO TWITHHOLES VALUES (11)
INSERT INTO TWITHHOLES VALUES (15)
INSERT INTO TWITHHOLES VALUES (NULL)

findHoles()
BROWSE

INSERT INTO TWITHHOLES VALUES (1)
INSERT INTO TWITHHOLES VALUES (100)

findHoles()

BROWSE

FUNCTION findHoles

	SELECT	NVL(T1.F1+1	,RANGESTART)	holeBegin		;
	,	NVL(MIN(T2.F1)-1,RANGEEND)	holeEnd			;
	INTO CURSOR THOLES						;
	FROM	(TWITHHOLES T1 LEFT JOIN TWITHHOLES T3 ON T3.F1=T1.F1+1);
		FULL	JOIN						;
		(TWITHHOLES T2 LEFT JOIN TWITHHOLES T4 ON T4.F1=T2.F1-1);
		ON T2.F1>T1.F1+1					;
	WHERE T3.F1 IS NULL AND T4.F1 IS NULL				;
	GROUP BY T1.F1							;
	HAVING NVL(T1.F1+1,RANGESTART)<=holeEnd
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform