Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is wrong with this Having clause?
Message
From
26/10/2005 18:16:10
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01062374
Message ID:
01062446
Views:
18
>>
>>This is the way, but it open THIS ISSUE: "the first fieldname is undefined":
>>
>>select MAX(&lcExpr), ;
>>   upper(&lcExpr) ;
>>   from (tcAlias) ;
>>   where not deleted() ;
>>   &lcFilter ;
>>   group by 2 ;
>>   having not empty(&lcExpr) ;
>>   into cursor (.cCursor)
>>
>
>I can see how adding MAX() would solve the problem with the SQL: Having clause. But what do you mean by the "THIS ISSUE"?

The MAX() consumes &lcExpr and then the first field name into cCursor
become "Max_MyField" and the HAVING fire a error.

If this is not a problem, then you can rewrite this :
select MAX(&lcExpr) as field1, ;
   upper(&lcExpr) ;
   from (tcAlias) ;
   where not deleted() ;
   &lcFilter ;
   group by 2 ;
   having not empty(field1) ;
   into cursor (.cCursor)
But remember, this is 99% match to the original, but not 100% equal .
CREATE CURSOR BYBY (AA C)
INSERT INTO BYBY VALUES ('a')
INSERT INTO BYBY VALUES ('A')

SET ENGINEBEHAVIOR 70
SELECT AA,UPPER(AA) FROM BYBY GROUP BY 2

SET ENGINEBEHAVIOR 90
SELECT MAX(AA),UPPER(AA) FROM BYBY GROUP BY 2
If you want 100% equal, use SET ENGINEBEHAVIOR 70 with the original select.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform