2016-07-27 81 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聚合。然後使用「追加流」步驟。