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_OrderByThis 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.
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 _valAleksey.