0

I want to get the count of the registered users in the past 7 days, grouped.

+-----+------------+--------------+
| id  | username   | created      |
+-----+------------+--------------+
|  1  | Vlad       | 1360168194   |
+-----+------------+--------------+
|  2  | Test       | 1360168194   |
+-----+------------+--------------+

This is my table. I want to have 7 rows of results with the date of the day, and count(id) as the result for the users that registered.

I tried different solutions and none of them really fitted my needings. Are there any ideas?

4

1 回答 1

2
SELECT  DATE(FROM_UNIXTIME(columName)), COUNT(ID) totalCOunt
FROM    tableName
WHERE   DATE(FROM_UNIXTIME(columName)) BETWEEN CURDATE() + INTERVAL -7 DAY AND CURDATE()
GROUP   BY DATE(FROM_UNIXTIME(columName))

其他来源

于 2013-02-06T16:35:59.527 回答