Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Probs with HAVING clause
Message
From
20/12/2017 14:08:42
 
 
To
16/12/2017 13:17:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012 R2
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Miscellaneous
Thread ID:
01656466
Message ID:
01656599
Views:
80
that fixed it. I was under the impression from the error message that I had to have something in there for each aggregated column (I think the error msg was either misleading or too generic). Reading some other posts elsewhere, it seems that the HAVING clause perhaps only works on an aggregated column. Here was a good summary:

"WHERE clause introduces a condition on individual rows; HAVING clause introduces a condition on aggregations, i.e. results of selection where a single result, such as count, average, min, max, or sum, has been produced from multiple rows. Your query calls for a second kind of condition (i.e. a condition on an aggregation) hence HAVING works correctly.

As a rule of thumb, use WHERE before GROUP BY and HAVING after GROUP BY. It is a rather primitive rule, but it is useful in more than 90% of the cases."

source: https://stackoverflow.com/questions/9253244/sql-having-vs-where

Thanks for the suggestion.
Albert

>What happens if you change "AS IndexRate" to AS "cIndexRate" -- thus eliminating any confusion as to the reference in the HAVING clause?
>
>Hank
Previous
Reply
Map
View

Click here to load this message in the networking platform