Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way to SUM alike records with a SELECT statem
Message
From
16/10/2000 16:52:25
 
 
To
16/10/2000 16:42:22
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00429156
Message ID:
00430028
Views:
20
>>>>select *,sum(jan_doll) as jan_money ,sum(feb_doll) as feb_money,;
>>>>from mysales;
>>>>order by part_number;
>>>>group by part_number;
>>>>into cursor mycursor....end of code...I am having a problem. The SUM is not right. Do I have to restart to SUM at the beginning of each group?
>>>
>...
>>Hi Nadya - working now...thanks....my imput data was wrong...:))
>
>It should work and glad working :) I only wanted to note 2 things Rob :
>1) select * (select all fields) is useless with aggregation functions unless you do it on purpose. Because you always get the last physically entered record for a group on other fields. ie:
>
>
PartName Date     Amount
>part1    1/1/2000    130
>part1    1/1/1999     20
>...
>
>select *, sum(amount) as AmountTot from ..
>
>returns
>
>PartName Date     Amount
>part1    1/1/1999    150
>
>no matter how you order.
>
>2) If group by expression is same as order by expression no need to 'order by' clause. SQL does an implicit order by on group by expression.
>Cetin
Hi Cetin:
Yes, I found that out how the GROUP BY works...thanks for letting me know about
ORDER BY clause......:)))
Robert Keith
Independent Developer
San Antonio, Texas
E-mail address:
rebelrob1@yahoo.com
Previous
Reply
Map
View

Click here to load this message in the networking platform