开发者

How to do query with timestamp?

开发者 https://www.devze.com 2023-01-24 15:11 出处:网络
I have this table: id (int) name (varchar) insert (timestamp) An example row is this: 14, John, 2010-02-25 01:48:36

I have this table:

id (int)
name (varchar)
insert (timestamp)

An example row is this:

14, John, 2010-02-25 01:48:36

In this table I have 1 million of rows and I want to know how many r开发者_开发百科ows have been inserted in each day. So I want something like this:

2010-02-25 153
2010-02-24 98
2010-02-23 219
2010-02-22 127
...

What query do I have to do ?


Try this:

SELECT DATE(`insert`) AS day, COUNT(*) AS cnt
FROM your_table
GROUP BY day

Note that days that have no rows will not be represented in the result set.

0

精彩评论

暂无评论...
验证码 换一张
取 消