Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP8.0, Group BY - URGENT

Status
Not open for further replies.

FoxLearner

Programmer
Aug 29, 2002
93
US
Hi all
I am facing a peculiar problem. I have a select statement like this:
SELECT sex, coverage, [06] AS agegrp, COUNT(age) AS agecount, agegroup, contract ;
FROM CensusTable ;
GROUP BY coverage, sex WHERE agegroup = "24"

This is working fine in VFP7.0 and 6.0. But in VFP8.0, I am getting an error:
"SQL: Group By Clause is missing or invalid".

Can some one come to my rescue?

Thanks and Regards
FoxLearner
 
Hi

SET ENGINEBEHAVIOR 70
will make a quick solution for all your such SQL problems. But follow the syntax and rectify soon to adapt to VFP8 will be better.

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Foxlearner,
You can also "fix" this by eliminating (or grouping on) the agegrp, agegroup and contract fields. As it stands these three fields are undefined in an SQL Select with a GROUP BY clause - they aren't being grouped and they aren't in a aggregate group function (SUM, COUNT, MIN, MAX, AVG, etc.).

Rick
 
It's fixed with a simple solution...it's called Read The Fine Manual (RTFM). IMO, SET ENGINE BEHAVIOR is not a good solution as the GROUP BY in previous versions could give ambiguous results. That's why the change was made in VFP8.

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
Craig
Thanks for your reply and time. However, would you please explain it a little more? I couldn't follow.
Thanks
FoxLearner
 
Craig means you should read the online help, specifically, "What's New in Visual FoxPro 8.0" and the subtopic, "Behavior Changes Since Visual FoxPro 7.0". That topic explains how SQL Select syntax has changed. To quote from that topic,

The GROUP BY clause must list every field in the SELECT list, except for fields contained in an aggregate function, such as the COUNT( ) function. In addition, the GROUP BY clause must also list every field in a HAVING clause, except for fields contained in an aggregate function.





-BP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top