Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql Group and total
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Sql Group and total
Miscellaneous
Thread ID:
01451592
Message ID:
01451592
Views:
102
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
Next
Reply
Map
View

Click here to load this message in the networking platform