select cust_no
,sum(case when order_status = 'shipped' then 1 else 0 end) as Shipped
,sum(case when order_status = 'open' then 1 else 0 end) as Open
,sum(case when order_status = 'waiting' then 1 else 0 end) as Waiting
from sales
group by cust_no
select cust_no
,sum(case when order_status = 'shipped' then 1 else 0 end) as Shipped
,sum(case when order_status = 'open' then 1 else 0 end) as Open
,sum(case when order_status = 'waiting' then 1 else 0 end) as Waiting
from sales
group by cust_no