如何获取字符串的最后一个字母并检查它是元音还是辅音?我正在使用oracle 10g。
这是我已经想出的:
SELECT last_name,
Substr(last_name, -1, 1) "Last letter",
Substr(last_name, 1, 1) "First letter",
CASE
WHEN Substr(last_name, -1, 1) IN ( 'a', 'e', 'i', 'o', 'u' ) THEN
'ends with a vowel'
WHEN Substr(last_name, -1, 1) IN ( 'b', 'c', 'd', 'f',
'g', 'h', 'j', 'k',
'l', 'm', 'n', 'p',
'q', 'r', 's', 't',
'v', 'w', 'x', 'y', 'z' ) THEN
'ends with a consonant'
END "Last Letter Description",
CASE
WHEN Substr(last_name, 1, 1) IN ( 'a', 'e', 'i', 'o', 'u' ) THEN
'starts with a consonant'
WHEN Substr(last_name, 1, 1) IN ( 'b', 'c', 'd', 'f',
'g', 'h', 'j', 'k',
'l', 'm', 'n', 'p',
'q', 'r', 's', 't',
'v', 'w', 'x', 'y', 'z' ) THEN
'starts with a consonant'
END "First Letter Description"
FROM employees
GROUP BY first_name,
last_name
现在,当您在 oracle 10g 上执行此操作时,“首字母描述”为空!我的代码有什么问题?