Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SELECT ... GROUP BY: VFP9 Best Practices?
Message
From
19/03/2006 20:27:51
 
 
To
19/03/2006 15:24:46
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01105667
Message ID:
01105708
Views:
20
This message has been marked as the solution to the initial question of the thread.
>
SELECT ;
>  WS_IP, ;
>  SomeFunc1(WS_IP) AS WS_IP_OrderBy, ;
>  PortProt, ;
>  PDomain, ;
>  SomeFunc2(PDomain) AS PDomain_OrderBy, ;
>  FDomain, ;
>  SomeFunc3(FDomain) AS FDomain_OrderBy, ;
>  COUNT(*) AS RequestCount ;
>  FROM RawLogs ;
>  INTO CURSOR ReportDriver ;
>  GROUP BY WS_IP, PortProt, PDomain, FDomain ;
>  ORDER BY WS_IP_OrderBy, PortProt, PDomain_OrderBy, FDomain_OrderBy
This approach works fine with ENGINEBEHAVIOR at 70 but blows up in 80 or 90 because the OrderBy columns are not in the GROUP BY list. I know I could temporarily set ENGINEBEHAVIOR to 70 for this query but I'd rather not, and 90 is more ANSI SQL compliant and is more likely to work on non-VFP backends.
>

Hi Al,

What VFP version are you using? This is a valid query for ENGINEBEHAVIOR 90 and should work with other backends too, the code below doesn't report any error for me.
SET ENGINEBEHAVIOR 90
CLOSE DATABASES ALL

? SET("EngineBehavior")

CREATE CURSOR RawLogs (WS_IP c(20), PortProt c(20), PDomain c(20), FDomain c(20))
APPEND BLANK

SELECT ;
  WS_IP, ;
  SomeFunc1(WS_IP) AS WS_IP_OrderBy, ;
  PortProt, ;
  PDomain, ;
  SomeFunc2(PDomain) AS PDomain_OrderBy, ;
  FDomain, ;
  SomeFunc3(FDomain) AS FDomain_OrderBy, ;
  COUNT(*) AS RequestCount ;
  FROM RawLogs ;
  INTO CURSOR ReportDriver ;
  GROUP BY WS_IP, PortProt, PDomain, FDomain ;
  ORDER BY WS_IP_OrderBy, PortProt, PDomain_OrderBy, FDomain_OrderBy

SELECT ReportDriver 
BROWSE 

FUNCTION SomeFunc1(_val)
RETURN _val

FUNCTION SomeFunc2(_val)
RETURN _val

FUNCTION SomeFunc3(_val)
RETURN _val
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform