使用 Oracle 19c:
我有以下查询,其中 Sub-Select (链接到主 Select via plans1_.ID
)使用该JSON_ARRAYAGG
功能。
select
... , /* Other columns... */
(SELECT
json_arrayagg(json_object('sentDate' value mh.sent_date,
'sentByEmail' value mh.send_by_email,
'sentBy' value mh.sent_by,
'sentByName' value mh.sent_by_name,
'sentToEmail' value mh.sendee_email) RETURNING CLOB)
from mail_history_t mh
where mh.plan_id = plans1_.id and mh.is_current_status = 'Y'
/*---This is the problem block: If I remove this ORDER BY the query works---*/
order by mh.sent_date desc
) as col_33_0_,
/* ... */
from TABLE_T table0_
left outer join PLANS_T plans1_
on table0_.SOME_ID=plans1_.SOME_ID
where ... /* etc. */
当我有order by
作为我的一部分时select from mail_history_t mh
,我得到了错误
00907. 00000 - "missing right parenthesis"
但是当我去掉这个order by
子句时,查询就起作用了。此外,如果我要隔离它,Sub-Select 会自行工作。
我的目标是获取具有满足条件的列的行的 JSON 数组表示,但按sent_date
DESC 排序。