查询报表增加小计功能

SELECT ISNULL(T1.KHMC, '总计')客户名称, ISNULL(T1.DJMC, '小计')单据名称, CAST(SUM(T1.SL) AS INT)数量
FROM   (
           SELECT vl.DM1, k.KHMC, vl.DJMC, vl.SL
           FROM   VW_LSXHDMX       AS vl
                  INNER JOIN KEHU  AS k ON  k.CKDM = vl.DM1
       ) T1
GROUP BY T1.KHMC , T1.DJMC WITH ROLLUP

posted @ 2017-12-20 10:54  liessay  阅读(255)  评论(0编辑  收藏  举报