36 - 按分类统计薪水
-- 方法一
select
'Low Salary' category,sum(income <20000) accounts_count
from
Accounts
union
select
'Average Salary' category,sum(income between 20000 and 50000) accounts_count
from
Accounts
union
select
'High Salary' category,sum(income>50000) accounts_count
from
Accounts ;
-- 方法二
select
'Low Salary' category,count(*) accounts_count
from
Accounts
where
income <20000
union
select
'Average Salary' category,count(*) accounts_count
from
Accounts
where
income between 20000 and 50000
union
select
'High Salary' category,count(*) accounts_count
from
Accounts
where
income>50000;