我在按 [评分] 列分组时遇到问题。当我执行它时,它给出“无效的列名'rate'”。
谁能帮我 ?谢谢!!
SELECT
......
CASE
WHEN level_1 = 'Corporate'
THEN
CASE
WHEN ssr.rating = 'A' OR ssr.rating LIKE 'A[+-]'
THEN 'Corp A'
WHEN ssr.rating = 'AA' OR ssr.rating LIKE 'AA[+-]'
THEN 'Corp AA'
WHEN ssr.rating = 'BBB' OR ssr.rating LIKE 'BBB[+-]'
THEN 'Corp BBB'
ELSE NULL
END
WHEN level_1 = 'Government' AND level_2 = 'Provincial'
THEN 'Prov'
WHEN level_1 = 'Government' AND level_2 = 'Federal'
THEN 'Canada'
ELSE NULL
END AS rating,
......
SUM(...)
.......
FROM....
GROUP BY rating