select case when b.name is null and c.name is null then '合计' when b.name is null and c.name is not null then '小计' else b.name end as mtrname,
sum(a.number),c.name as cname from x_sell a join x_material b on a.mtr=b.fid join p_organi c on c.fid=a.customer
where a.stime>'2009-10-01'
GROUP BY c.name,b.name WITH ROLLUP
order by c.name desc,b.name desc
用sql写小计和合计
最新推荐文章于 2022-04-02 16:21:40 发布