Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select records that fall 3 consecutive days within a wee
Message
De
23/12/2003 11:38:42
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
À
21/12/2003 23:03:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00861173
Message ID:
00861662
Vues:
13
Hi Evelyn,

I'm not sure exactly what you want, but something like this will get you started:
*!* I have table dtr with fields empno, swipedate and ti1 (logical). 
*!* I want to select all ti1 = .t. for every employee 
*!* that falls in 3 consecutive days within a week.

CREATE CURSOR Dtr (Pk I, EmpNo I, SwipeDate D, Ti1 L)

INSERT INTO Dtr VALUES (1, 1, {12/01/2003}, .F.)
INSERT INTO Dtr VALUES (2, 1, {12/02/2003}, .T.)
INSERT INTO Dtr VALUES (3, 1, {12/03/2003}, .T.)
INSERT INTO Dtr VALUES (4, 2, {12/04/2003}, .T.)
INSERT INTO Dtr VALUES (5, 2, {12/05/2003}, .F.)
INSERT INTO Dtr VALUES (6, 2, {12/09/2003}, .F.)
INSERT INTO Dtr VALUES (7, 3, {12/07/2003}, .F.)
INSERT INTO Dtr VALUES (8, 3, {12/08/2003}, .T.)
INSERT INTO Dtr VALUES (10, 3, {12/09/2003}, .T.)
INSERT INTO Dtr VALUES (11, 3, {12/10/2003}, .F.)
INSERT INTO Dtr VALUES (12, 3, {12/11/2003}, .T.)
INSERT INTO Dtr VALUES (13, 3, {12/12/2003}, .T.)

SELECT DISTINCT Dtr.EmpNo ;
	FROM Dtr ;
	INNER JOIN Dtr AS Day2 ON ;
		(Dtr.EmpNo = Day2.EmpNo) AND (Dtr.SwipeDate = Day2.SwipeDate - 1) ;
	INNER JOIN Dtr AS Day3 ON ;
		(Dtr.EmpNo = Day3.EmpNO) AND (Dtr.SwipeDate = Day3.SwipeDate - 2)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform