假设表中有字段id,time,格式为Unix时间戳,现需要按照该字段统计每天的记录数。
方法:
group by from_unixtime(time,'%Y%m%d') 即可。
例子:
select sum(id) from table group by from_unixtime(time,'%Y%m%d');
按月,按年分组方法一样,只需要修改from_unixtime方法第二个参数。
假设表中有字段id,time,格式为Unix时间戳,现需要按照该字段统计每天的记录数。
方法:
group by from_unixtime(time,'%Y%m%d') 即可。
例子:
select sum(id) from table group by from_unixtime(time,'%Y%m%d');
按月,按年分组方法一样,只需要修改from_unixtime方法第二个参数。