Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group by clause
Message
From
18/04/2005 04:43:15
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01005559
Message ID:
01005697
Views:
17
D_debut = {^2005/04/01}
d_fin   = {^2005/04/30}

SELECT ;
 	H.iemployeeid;
, 	COUNT(p.iid) totalp1;
, 	COUNT(p2.iid) totalp2;
	FROM Horaire H;
	LEFT JOIN PAUSE P ON P.iid   = H.cpauseid;
	LEFT JOIN PAUSE P2 ON P2.iid = H.cpauseid2;
    WHERE (H.cpauseid <> 0 OR H.cpauseid <> 0); 
       AND H.ddate BETWEEN m.D_debut  AND m.d_fin;
    GROUP BY 1 ;
INTO CURSOR TEMP
BROWSE

* WITH REFERENTIAL Integrity THIS IS LIKE COUNT cpauseid#0
* DAY(NULL) IS A FAST CAST
SELECT ;
 	H.iemployeeid;
, 	COUNT(EVL(H.cpauseid,DAY(NULL))) totalp1;
, 	COUNT(EVL(H.cpauseid2,DAY(NULL))) totalp2;
	FROM Horaire H;
    WHERE (H.cpauseid <> 0 OR H.cpauseid <> 0);
     AND H.ddate BETWEEN m.D_debut  AND m.d_fin;
    GROUP BY 1 ;
INTO CURSOR TEMP2
BROWSE
RETURN
Point 1:
If you change cpauseid=0 to null ( same for cpauseid2 )
the sql commands are more simple and portable.

Another point:
you define
INDEX ON DELETED() TAG DELREC
This is not good.

On VFP9 you can use
INDEX ON DELETED() TAG DELREC BINARY && 4X faster and bloat insensible
but this is not the best solution.

Best is:
* erase DELREC 
* change
INDEX ON iid FOR NOT DELETED() TAG primary
With this VFP9 use primary for to exclude the deleted records,
and when you use a PK match, VFP optimize the match and the deleted() test
with a single index!

Best if you add FOR NOT DELETED() on all the tags.

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform