Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select query group worked fine in v7 Not in v8: What changed
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Select query group worked fine in v7 Not in v8: What changed
Miscellaneous
Thread ID:
00812429
Message ID:
00812429
Views:
54
The following select query worked OK when run previously in v7 against the source data but not OK when run in v8 against the same source data derived from the same origin with the same initiating sqlexec() sql query.

The desired resultant data is being 'selected' as shown below from a source view of data initially derived from an sqlexec(handle, "SELECT data FROM JOINED tables, etc", to_cursor) type select statement gathering the original data that is to be queried by this next sql statement (as below) from an W2K SQL database that has not changed.

The question here is: Why is v8 objecting to this syntax whereas v7 has no problem with it? In v8, running the whole query (including the initial sqlexec() part to gather the source data) now gives error message: "SQL: GROUP BY clause is missing or invalid."

Here is the statement: (Note. the && ...comments... shown below are not in the actual query as run; they are included herein only for reference to help clarify the underlying data that is being queried)
SELECT ;
            COUNT(*), ;
            a.hosp_id, ;                                    && this field is a combination of 'all' printable characters to form a "key"
            a.pat_id, ;                                       && this field is a combination of 'all' printable characters to form a "key"
            a.control, ;                                      && this field is a conventional 'account number' of alpah-numeric characters
            a.name, ;                                        && this field is a person name field - conventional alpha
            TTOD(a.date) AS serviced, ;      && this is event date - has potential for nulls but none are in the source data under query.
            SUM(a.amount) AS ttlichgs ;      && this is currency - has potential for nulls but none are in the source data under query.
   FROM ;
            icharges_cursor a ;
   INTO CURSOR ;
            ibchgsttl_cursor ;
   GROUP BY ;
            a.pat_id, a.control

Reducing the query down to a single field, such as "a.name" as in:
SELECT ;
            COUNT(*), ;
            a.name ;
   FROM ;
            icharges_cursor a ;
   INTO CURSOR ;
            ibchgsttl_cursor ;
   GROUP BY ;
            a.name

Or any other single field such as "a.control" and changing GROUP BY to matching "a.control" immediatly results in the query running without problem, but add back any other field so now the query calls for 2 or more fields, and the same error message is given.

So what am I doing wrong or what has changed between v7 and v8 that makes this query no longer runnable? TIA. /psb
Next
Reply
Map
View

Click here to load this message in the networking platform