X
xuxiaohan
Unregistered / Unconfirmed
GUEST, unregistred user!
select case when grouping(comput) = 1 then '合计' <br> when grouping(ddbh) = 1 then '--' else comput end as 部件编号, <br> case when grouping(ddbh) = 1 then '订单合计' <br> else ddbh end as 订单编号, <br> sum(ddsl) as 订单数量 from #temp<br> group by comput, ddbh with rollup <br><br><br>部件编号 订单编号 订单数量<br>500-315W01W030 LI072401 80<br>500-315W01W030 LI072880 86500<br>500-315W01W030 LI090729 51800<br>500-315W01W030 LI092852 13600<br>-- 订单合计 151980 有多条记录,返回这一行<br><br>500-315W01W040 LI092923 3110<br> 订单合计 3110 只有一条记录,不想返回这一行,怎么做?<br>合计 订单合计 155090