I have a MYSQL database that contains data on my companies customers as they use our services each day.
each table in the database represents one 24 hour period and all customer transactions that took place in that period.
I would like to count the total transactions over a number of days
so far I have a select statement that does the following
select
(
select count(customer) from 2010Dec28
where customer='<customer name>'
) as t1,
(
select count(customer) from 2010Dec29
where customer='<customer name>'
)as t2;`
but this returns the result as two separate counts
| t1 | t2 |
| 1438 | 16282 |
1 row n set (0.00 sec)`
My question is how can I generate the sum of these two results without having to do so in my application code.
UNION ALLquery to combine multiple queries into one, then wrap the whole union into anotherSELECTtoSUMall the counts.