Suppose I have a table called "productClick" like this:
----id------click-------------ctime----------
| 1 | 5 | 2015-12-26 00:01:12 |
---------------------------------------------
| 2 | 2 | 2015-12-27 00:01:12 |
---------------------------------------------
| 3 | 7 | 2015-12-28 00:01:12 |
---------------------------------------------
| 4 | 1 | 2015-12-28 00:01:12 |
---------------------------------------------
I want to get total number of product, today's total number of product added and sum of total click.
I have three separate queries like this:
SELECT COUNT(*) as totalProduct FROM productClick
SELECT COUNT(*) as todayTotalProductAdded FROM productClick WHERE DATE(`ctime`) = CURDATE()
SELECT sum(click) as totalClick FROM productClick
It works fine. But I want to combine this three separate queries into one query. How to achieve this?
UPDATE
Question updated. Sorry for my fault. Thanks @Gordon Linoff
todayClickreallyCOUNT(*)? Shouldn't it beSUM(click)?