select month(time),sum(amount) from table group by month(time)
##区分年份
select month(time),sum(amount) from table group by extract(year_month from time)
望采纳……
$nowtime=date("Y-m-d H:i:s")$endtime=date("Y-m-d H:i:s",(strtotime("+30 days",strtotime($nowtime))))//加上30天
$endtime=date("Y-m-d H:i:s",(strtotime("+2 months",strtotime($nowtime))))//加上2个月,减少的话用 减号" -"
SELECT SUM(field_name) FROM tblName WHERE UNIX_TIMESTAMP(month) <= DATE_ADD(CURRENT_DATE(),INTERVAL -1 MONTH) GROUP BY month欢迎分享,转载请注明来源:内存溢出
评论列表(0条)