目前我有一张桌子
id amount_spend 1 10 2 20 3 30 4 40 5 50
我想添加名为category
的第三列,它应显示:
请让我知道如何在选择声明中添加它。
答案 0 :(得分:3)
select id,
amount_spend,
case
when amount_spend > 30 then 'high'
when amount_spend > 20 and amount_spend <= 30 then 'medium'
else 'low'
as category
from the_table;