- 查询截止到每个月总开票量(使用了变量)
select @count_m:=0;
select t_time as '时间', @count_m:=total+@count_m as '开票量' from
(SELECT DATE_FORMAT(created_at,'%Y-%m') as t_time,count(*) as total FROM invoice GROUP BY t_time ) t group by t_time;
- 查看正在执行的事物,排查是否有数据被锁住
SELECT * FROM information_schema.INNODB_TRX