Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group by clause
Message
 
 
To
27/02/2012 08:25:20
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01536615
Message ID:
01536617
Views:
47
>Hi friends:
>
>This is what I always wanted to do but I've never got it.
>
>Anyone can tell me what is the correct way for "grouping by" in a SELECT SQL command?
>
>I tried FROM field table, INTO CURSOR field and 1 (result column field) and none of them worked.
>
>This is just one of my tests:
>
> SELECT SUBSTR(f850nfac,2,4) as cpues, f850grav as cgrav, f850ivai as civai, f850exen as cexen, f850tota as ctota, .t. as celijo ;
> FROM &ivaventa WHERE LEFT(DTOS(f850ffac),6)==thisform.peri GROUP BY CPUES NOCONSOLE INTO CURSOR cpuesto
>
>Thank you.
>
> Héctor


All fields, that are not listed in GROUP BY clause, must be in any aggregate function.

So, your query will be
>   SELECT SUBSTR(f850nfac,2,4) as cpues, f850grav as cgrav, f850ivai as civai, f850exen as cexen, SUM(f850tota) as ctota, .t. as celijo ;
>          FROM &ivaventa WHERE LEFT(DTOS(f850ffac),6)==thisform.peri GROUP BY 1,2,3, NOCONSOLE INTO CURSOR cpuesto
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform