我正在做一个 pokemon sql 表并创建了一个名为 capacity_difference 的新列来确定表中每个 pokemon 的可收集性。但是,当我想使用 CASE 查询对它们进行分类时,结果只显示每个日志的 ELSE 条件。有人可以告诉我如何修复查询吗?
我的查询如下:
ALTER TABLE pokemon add capacity_difference INTEGER;
SELECT name, type_1, type_2, HP, (attack - defense) as capacity_difference from pokemon;
SELECT name, type_1, type_2, HP, (attack - defense) as capacity_difference,
CASE
when capacity_difference > 90 then "collect asap"
when capacity_difference < 90 and capacity_difference > 50 then "good"
when capacity_difference > 0 and capacity_difference < 50 then "okay"
when capacity_difference > -10 and capacity_difference < 0 then "bad"
ELSE "worse"
END AS Collectability
FROM pokemon;