Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select Statement help
Message
De
07/06/2002 18:47:51
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
07/06/2002 14:10:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00666106
Message ID:
00666199
Vues:
17
>Hi All,
> I have need of a select statement that adds certain values and returns a single record out of, for example, two records.
>
>
 1   GLOC  20228       9.33247      1.10   92.16   1    T   P   1
> 2   GLOC  17533       5.00000      1.10   92.16   1    T   P   2
>
>The select statement would preferably return
>
>
1   GLOC  20228       14.33247      1.10   92.16   1    T   P   1
select Field1, sum(Num1) as Total_Num1, sum(Num2) as Total_Num2;
  from MyTable;
  group by Field1
Several records that have the same value for Field1 will be grouped together. sum() will take care of adding the values in the required fields.

For fields that have different values, and are not summed, you can't trust that a specific value will be selected. But perhaps you can select min(pk), and then add a second SELECT statement or a subquery.

HTH, Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform