Oracle 错误 - ORA-00907:缺少右括号
我对这个 Oracle 错误感到摸不着头脑。以下查询完美运行:
SELECT
V.PROJECTID,
(SELECT WM_CONCAT(DISTINCT NAME)
FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS USING (METHODID)
WHERE PROJECTID=V.PROJECTID
AND VERSIONID=V.VERSIONID) as Methods
FROM TPM_PROJECTVERSION V
但是,我想按字母顺序返回我的连续列表,因为我很挑剔。您可能会认为我会这样做:
SELECT
V.PROJECTID,
(SELECT WM_CONCAT(DISTINCT NAME)
FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS USING (METHODID)
WHERE PROJECTID=V.PROJECTID
AND VERSIONID=V.VERSIONID ORDER BY NAME) as Methods
FROM TPM_PROJECTVERSION V
但是,当我尝试这样做时,我收到错误:
[Error] Script lines: 15-19 ------------------------
ORA-00907: missing right parenthesis
我可以在其自己的 SELECT 语句中运行查询,如下所示:
SELECT WM_CONCAT(DISTINCT NAME)
FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS USING (METHODID)
WHERE PROJECTID=240
AND VERSIONID=1
ORDER BY NAME
并且它运行良好。我的括号比太阳马戏团更平衡。为什么会出现错误?
I'm scratching my head over this Oracle error. The following query works perfectly:
SELECT
V.PROJECTID,
(SELECT WM_CONCAT(DISTINCT NAME)
FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS USING (METHODID)
WHERE PROJECTID=V.PROJECTID
AND VERSIONID=V.VERSIONID) as Methods
FROM TPM_PROJECTVERSION V
However, I want to return my concantonated list in alphabetical order because I'm picky like that. You'd think I would do:
SELECT
V.PROJECTID,
(SELECT WM_CONCAT(DISTINCT NAME)
FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS USING (METHODID)
WHERE PROJECTID=V.PROJECTID
AND VERSIONID=V.VERSIONID ORDER BY NAME) as Methods
FROM TPM_PROJECTVERSION V
However, when I try this I get the error:
[Error] Script lines: 15-19 ------------------------
ORA-00907: missing right parenthesis
I can run the query in its own SELECT statement, like so:
SELECT WM_CONCAT(DISTINCT NAME)
FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS USING (METHODID)
WHERE PROJECTID=240
AND VERSIONID=1
ORDER BY NAME
And it runs fine. My parenthesis are more balanced than a Cirque du Soleil troop. Why the error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为聚合的 WM_CONCAT 函数不受 ORDER BY 的影响。
因此,正如所承诺的,对结果进行排序的自定义聚合。也可以在早期版本中使用。
现在您的查询可能如下所示:
I think the aggregated WM_CONCAT function isn't affected by ORDER BY.
Therefor, as promised, a custom aggregation that sorts the results. Can be used in earlier versions too.
Now your query could look something like this:
尝试
但我认为你应该添加一个 WHERE 子句来连接两个表......
try
But I think you should add a WHERE clause for joining the two tables....