Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What wrong with this SQL?
Message
 
To
27/05/2001 10:39:01
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00511889
Message ID:
00511894
Views:
22
Hello John,

You can only do group by on existing columns in the resulting cursor. So this means your sql statement should look something like this:
SELECT MONTH(rptDT) as grpMonth, YEAR(rptDT) as grpYear, SUM(HourReq) as sumHourReq, SUM(HourUsed) as sumHourUsed, SUM(HourOT) as sumHourOT, SUM(ManPower) as sumManPower ; 
FROM tblRequest ;
GROUP BY grpYear,grpMonth ;
INTO CURSOR csr
Also, I used the sum() to sum all hours by group, (see the VFP help for all other functions that can be used this way in a sql-select statement) If you don't use this, vfp will show you the value of a record but I wouldn't program it this way because there is no way to know which record is used. It could change in a next version of vfp. As a matter of fact, you must use a function like sum() for all non-grouped fields if you want to use the same sql statement in SQL Server.

hth,
Frank Camp
Previous
Reply
Map
View

Click here to load this message in the networking platform