Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sum from fields in two tables
Message
 
To
16/11/2008 12:57:35
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01362166
Message ID:
01362168
Views:
12
>I have to sum two fields. Same field name but in two different tables.
>
>Right now I sum and join but I end-up with two sums for the same Id.
>
>How do I sum everything without intermediate sums (because of the joins) ?
>
>I guess that "where in (select...) would be involved but I'm sot sure how to build this.

Try:
SELECT somefield, SUM(Tbl1.Fld1 + Tbl2.Fld1) AS ???;
FROM Tbl1;
INNER JOIN Tbl2 ON ....
GROUP BY ...
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform