Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Probs with HAVING clause
Message
From
15/12/2017 18:37:47
 
 
To
15/12/2017 17:52:27
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:
01656467
Views:
60
>Hi all,
>
>Having trouble with the HAVING clause in this query if SET ENGINEBEHAVIOR 90.
>
>
>
>SELECT ;
>   App_ID, MAX(IndexRate) AS IndexRate, MAX(PurchaseDate) AS PurchaseDate, MAX(YEAR(PurchaseDate)) AS Year ;
>   FROM AppStreams ;
>   WHERE NOT CPIIndexed ;
>   GROUP BY App_ID ;
>   HAVING IndexRate > 0 ;
>   INTO CURSOR IndexedApps   
>
>
>
>VFP complains about the HAVING clause. If I revert back to SET ENGINE 70, it's okay. The help notes say that I have to list all the columns except aggregating columns in the HAVING clause.
>
>I thought that "HAVING" was like a "post-grouping" WHERE clause i.e. VFP first does the grouping and then it applies the HAVING to the result of that to yield a subset.
>
>I am not even sure what other column I would put in that HAVING clause.
>
>Albert

HAVING uses aggregate or grouped or constant values, which is not happening in your case.
SELECT ;
   App_ID, MAX(IndexRate) AS IndexRate, MAX(PurchaseDate) AS PurchaseDate, MAX(YEAR(PurchaseDate)) AS Year ;
   FROM AppStreams ;
   WHERE NOT CPIIndexed ;
   GROUP BY App_ID ;
   HAVING MAX(IndexRate) > 0 ;
   INTO CURSOR IndexedApps 
----------------------------------
António Tavares Lopes
Previous
Reply
Map
View

Click here to load this message in the networking platform