mysql小计合计

语法 select * from 表名 group by ...with rollup

select
        ifnull(line, '总计') line,
        ifnull(vehicle, if(line!='总计','小计','合计')  ) vehicle,
        DATE_FORMAT(out_time,'%Y-%m-%d') as out_time,
        sum(minor_repair) minor_repair, sum(middle_repair) middle_repair,
        sum(face_lifting) face_lifting, sum(accident) accident,
        sum(total_amount) total_amount
        from report_out_depot
        where delete_flag = '0' and valid = '1' 
        group by line, vehicle
        with rollup

上一篇:基于Prometheus的Pushgateway实战


下一篇:【LeetCode】-数组