SQL语句 = “SELECT 字段1, SUM(字段2) as 合计 FROM 表名 WHERE 字段2='你好' GROUP BY 字段1”
试试
你可以按年月分组,然后用last_day()函数取每月最后一天,然后在用date_sub()函数往前取90天的销售额求和,举个栗子:select date,sum(sales) from tablename a left join (select date from tablename group by last_date(date)) b on a.date=b.date and a.date>=date_sub(curdate(),interval 90 day) and a.date<=b.date group by b.date
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)