Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question on the VFP 9 group by
Message
From
06/04/2006 14:09:19
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01111136
Message ID:
01111137
Views:
22
>I need to find the employee id for the employee that has the most hours for each given work type.
>
>In VFP 6 the following SQL Select would work fine:
>
SELECT  worktype, MAX(asgnhrs), emplid FROM john GROUP BY worktype
>
>In VFP 9 I am trying to do things the new way without useing the set enginebehavior 70 command. Of course this generates the "Invaid Group By" error becuase I have not included the emplid in the group by. But, if I did, I would get all the emplyees. What do I need to change to get only the emplyee id with the max hours?
>TIA.

You must include all the fields, except the aggregate fields, in the group by list
>
SELECT  worktype, MAX(asgnhrs), emplid FROM john GROUP BY 1,3
or
>
SELECT  worktype, MAX(asgnhrs), emplid FROM john GROUP BY worktype,emplid
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform