2017-02-09 219 views
-3
AWBNO    STATUS 
123    DELIVERED 
125    DELIVERED 
124     RTO 
126     RTO 
127     NDR 
128     NDR 
131    DELIVERED 
132    DELIVERED 
133     NDR 
134    DELIVERED 

我想用這種方式輸出: -計算總計值

TOTAL  DELIVERED  RTO  NDR 
10    5   2  3 
+4

...加油,更具描述性。添加您的代碼和一些細節。 – Laurens

回答

3

你可以根據狀態這樣的條件彙總:對人

select 
    count(*) total, 
    count(case when status = 'DELIVERED' then 1 end) DELIVERED, 
    count(case when status = 'RTO' then 1 end) RTO, 
    count(case when status = 'NDR' then 1 end) NDR 
from your_table;