Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a way to SUM alike records with a SELECT statem
Message
De
16/10/2000 14:36:48
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00429156
Message ID:
00429918
Vues:
22
>>>>>>In vfp60, Is there a way to SUM alike records with a SELECT statement?
>>>>>>I have a table with a field called part_number. This table is ORDER BY part_number...There are many records that contain the same
>>>>>>part_number values and I want to SUM these records so I have
>>>>>>a DISTINCT on part_number and the part_number values will be totaled and represented in one record for each part_number...any ideas?
>>>>>
>>>>>select part_number, sum(numfield) as myTotal from mytable group by part_number
>>>>>Cetin
>>>>--------
>>>>Hi Certin....Nice to hear from you again...my numfidld is non-numeric...
>>>>and the SUM will not work...:)
>>>
>>>Thanks Rob. Then what will you sum ? You mean something like distinct row or what ? Or you mean a cross-tab ?
>>>Cetin
>>Hi Cetin- I will sum field values in a group of records with the same part number..Here is my code:
>>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?
>
>Robert,
>SUM in SQL "restarts" automatically, you don't have to do anything. Could you show your data? Why do you think, that the sum is not right?
>
>Part_Number  Jan_Doll   Feb_Doll
>  1          10         20
>  1          20         30
>  2          10         10
>  2          15         20
> etc.
>
>Your select statement should return
>
>Part_Number  Jan_Money   Feb_Money
> 1           30          50
> 2           25          30
>
Hi Nadya - working now...thanks....my imput data was wrong...:))
Robert Keith
Independent Developer
San Antonio, Texas
E-mail address:
rebelrob1@yahoo.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform