Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql Group and total
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Sql Group and total
Divers
Thread ID:
01451592
Message ID:
01451592
Vues:
103
I have a table as folows:

Inv No. Continent Country INV_VAL Town Units_SOLD

1 EUROPE UK 100 LONDON 10
1 EUROPE UK 100 MANCHESTER 3

2 EUROPE UK 500 LIVERPOOL 1
2 EUROPE UK 500 BIRMINGHAM 4


3 ASIA CHINA 300 BEJING 23
3 ASIA CHINA 300 SHANGHAI 12


I want to do a sql select which totals and groups by Continent/Country but ensure
that the INV_VAL column is also totalled correctly.
If I do a sum(Inv_Val) I will get 1200 for Europe instead of 600 (100 + 500)
The Inv_Val already has the total INV_VAL for each invoice.

The resuting table that I need is
Continent Country CTRY_SALES POP_TOTAL
EUROPE UK 600 18
ASIA CHINA 300 35

I have'nt been able to figure out a way to do this with one Sql Seelct command
and am wondering if its possible.
Tia,
Gerard
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform