2016-07-27 77 views

回答

4

您可以使用group by with rollupifnull一起:

select ifnull(customer, 'Total') customer, sum(qty) 
from yourtable 
group by customer 
with rollup 
+0

感谢您的回答。 –

+0

惊人的,从来没有见过之前.... – shzyincu

0

你可以做这样(语法为每个SQL服务器):

select Customer,sum(Qty) 
from whatevertable 
group by Customer 
Union 
select 'Total' as Customer,sum(Qty) 
from whatevertable 
0

在Pentaho Kettle(PDI):从一个步骤拖动两个跳绳,然后确保你选择'复制'。其中一个输出流可用于聚合Customer级别,另一个可用于获得Total聚合。然后使用“追加流”步骤。