mysql将日期转化再分组,MySQL按日期分组并从unix时间戳转换

I have the following sql table (simplified)

ID (int) title (text) date (int)

--------------------------------------------

1 Hello World 1378148920

2 Hello World2 1378182183

3 Hello World3 1378129838

4 Hello World4 1378146160

5 Hello World5 1378138038

....

The table has thousands of entries.

I wan't to ask you if it is possible to build a SQL query that groups all the posts by date but only as day.

So at the end I wan't to build a graph like this (for the last 5 days):

02.09.2013: 13 posts

01.09.2013: 14 posts

NOTE: the timestamp aren't real (they are all from today)

解决方案select FROM_UNIXTIME(`date`, '%d.%m.%Y') as ndate,

count(id) as post_count

from your_table

group by ndate

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值