Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group by clause is missing or invalid - but it is not!!
Message
From
14/07/2006 20:47:32
 
 
To
14/07/2006 01:00:30
Ian Johnston
Computer Software Solutions
Woodland, California, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01136284
Message ID:
01136608
Views:
17
Hi Ian,

>Yikes! I am moving a vfp7.0 app to 9.0, it use sum and group by in a lot of routines. Do you have to group by on all the columns?

No, your SUM() columns will be fine. These are called aggregate columns because they aggregate across the group. Other aggregate columns are MIN(), MAX(), etc.

You can always do this:
SELECT MyField1, SUM(MyField2), MIN(MyField3), MAX(MyField4);
FROM MyTable;
GROUP BY MyField1;
INTO CURSOR MyCursor

This will work out just fine.

You *cannot* do this:

SELECT MyField1, SUM(MyField2), MIN(MyField3), MAX(MyField4), MyField5;
FROM... GROUP BY MyField1... INTO

because MyField5 can have multiple values for different rows that are being grouped.

Someone suggested SET ENGINEBEHAVIOR 70 but I strongly discourage this. You should write the SQL correctly so it gives unambiguous results, as Dan and Craig pointed out. Also, you might want to use SQL features from VFP 9.0 and you cannot do this with SET ENGINEBEHAVIOR 70.

Does this help? If any more questions, please ask!
Best regards, Chaim
Previous
Reply
Map
View

Click here to load this message in the networking platform