To: "MySql List" <[EMAIL PROTECTED]>
Sent: Saturday, November 20, 2004 10:46 AM
Subject: summing from multiple tables
mysql> select sum(amount), sum(totaltimesviewed) from bill, pageviewed; +-------------+-----------------------+ | sum(amount) | sum(totaltimesviewed) | +-------------+-----------------------+ | 154.00 | 84 | +-------------+-----------------------+ 1 row in set (0.00 sec)
Why don't I get "30.80" and "12"? How can I change the query so I do get that result? What in the world did I actually do to get "154.00" and "84"? I can't see how anything adds up to those numbers...
that's because you didnt specify the join between two tables..
and so mysql will return a total of (number of records in bill) x (number of records in pageviewed)
and that's where the sum() value you got come from
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]