select store_code,
count(*) "總單數",
sum(case when so.paid_amount>300 then 1 else 0 end ) as "大於300的訂單數",
sum(so.paid_amount>300) as "=》大於300的訂單數",
sum(case when so.paid_amount>300 then 1 else 0 end ) / count(*) as "大於300的訂單佔比",
avg(so.paid_amount>300) as "大於300的訂單佔比2",
sum(so.paid_amount) as "銷售總額"
from sales_order so
group by store_code order by store_code