Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP8 GROUP BY Restriction
Message
From
29/05/2003 09:56:06
 
 
To
28/05/2003 18:53:46
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00793077
Message ID:
00793909
Views:
26
In my SQL statement below, I retrieve not only the numsales field which has the MAX value, but the company and zip from that record. As a result, it lists every company and zip which has the largest numsales for each custnum. This code looks like a kludge and I'm not 100% certain it works. If any of you know of a better way, I'll love to know.


******** CODE ********

SELECT custnum, MAX(numsales) AS numsales, ;
LEN(MAX(numsales)) AS numsales_len, ;
MAX(numsales+company) AS company, ;
MAX(numsales+zip) AS zip ;
FROM db_main ;
GROUP BY custnum ;
INTO CURSOR tmp_cursor0

SELECT custnum, numsales, ;
SUBSTR(company, numsales_len+1) AS company, ;
SUBSTR(zip, numsales_len+1) AS zip ;
FROM tmp_cursor0 ;
INTO CURSOR tmp_cursor


******** END CODE ********
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform