General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only