我正在select子句中使用以下CASE语句执行查询:
select (case instr(listagg(D.first_name, ',')
within group (order by D.first_name), ',')
when 0
then substr(listagg(D.first_name, ',')
within group (order by D.first_name), 1)
else substr(listagg(D.first_name, ',')
within group (order by D.first_name), 1, instr(listagg(D.first_name, ',')
within group (order by D.first_name), ',') - 1) end) Advisor1FName
from ....
SQL Developer抛出一个ORA-00907错过右侧的paranthesis错误。
出了什么问题?任何帮助将不胜感激。
答案 0 :(得分:2)
通过将整个listagg函数括在括号中来解决。奇怪的是,他们是必需的,但这就解决了这个问题。
所以,
substr(listagg(D.first_name, ',')
within group (order by D.first_name), 1)
变为
substr((listagg(D.first_name, ',')
within group (order by D.first_name)), 1)