由于楼主没有具体之名什么东西 现也只能 给你个简单例子,楼主可以自己扩展,能够实现你的需求的。按年汇总,统计: select sum(mymoney)as totalmoney,count(*) as sheets from mytable where 1 group by date_format(col,'%Y') ;按月汇总,统计: select sum(mymoney)as totalmoney,count(*) as sheets from mytable where 1 group by date_format(col,'%Y-%m') ;按季度汇总,统计: select sum(mymoney)as totalmoney,count(*) as sheets from mytable where 1 group by concat(date_format(col,'%Y'),FLOOR((date_format(col,'%m')+2)/3)) ;按小时: select sum(mymoney)as totalmoney,count(*) as sheets from mytable where 1 group by date_format(col,'%Y-%m-%d %H') ;好了,就到这里吧。
现也只能 给你个简单例子,楼主可以自己扩展,能够实现你的需求的。按年汇总,统计:
select sum(mymoney)as totalmoney,count(*) as sheets from mytable where 1 group by date_format(col,'%Y') ;按月汇总,统计:
select sum(mymoney)as totalmoney,count(*) as sheets from mytable where 1 group by date_format(col,'%Y-%m') ;按季度汇总,统计:
select sum(mymoney)as totalmoney,count(*) as sheets from mytable where 1 group by concat(date_format(col,'%Y'),FLOOR((date_format(col,'%m')+2)/3)) ;按小时:
select sum(mymoney)as totalmoney,count(*) as sheets from mytable where 1 group by date_format(col,'%Y-%m-%d %H') ;好了,就到这里吧。