Reply to Sum question

Your name:

Reply:


Posted by rich on 05/03/07 11:10

Hi

I'm new to SQL and am having trouble figuring this one out. Any help
would be very much appreciated.


I have 2 tables 'A_Totals' & 'B_Totals' each table is identical in
construction, each column is labeled Date,Total1,Total2,Total3 up to
Total 18.


I have written some sctipts that populates these tables everyday.


To get a total e.g of Total3 I have used the following SQL statement


For A_Totals:
SELECT sum(total3) FROM A_Totals
This returns 18596


For B_Totals
SELECT sum(total3) FROM B_Totals
This returns 21794


I would like to create just 1 SQL statement to return both totals so
I
tried
SELECT sum(A_Totals.total3),sum(B_Totals.total3) FROM
A_Totals,B_Totals
but this returns 1710832.00 ,1961532.00 and I can't figure out
why :o(


i also would like to create a statement that gives me a combined
total
e.g.
SELECT sum(A_Totals.total3) + sum(B_Totals.total3) FROM
A_Totals,B_Totals
this is returning 3672364.00


Thanks in advance


Rich

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация