在我的 oracle 查询中遇到“ORA-00923:FROM 关键字未在预期位置找到”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15548077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"ORA-00923: FROM keyword not found where expected" Encountered in my oracle query
提问by Tas
SELECT TITLE, CONCAT(TO_CHAR(SUM((COST-RETAIL)/COST)*100), '100'), '%')
AS "Markup"
FROM BOOKS
GROUP BY TITLE;
::THE GOAL::
I'm trying to calculate the mark-up for my products (books).
::目标::
我正在尝试计算我的产品(书籍)的加价。
::ZE PROBLEM::
When I try to run the stated SQL, I get the error
::ZE 问题::
当我尝试运行指定的 SQL 时,出现错误
ORA-00923: FROM keyword not found where expected
ORA-00923: 未在预期位置找到 FROM 关键字
In advance I thank you for any and all input on my issue.
在此先感谢您对我的问题的所有意见。
回答by munch1324
Your parentheses are not balanced I count 4 left and 5 right. This error usually happens when there is a formatting error that prevents the FROM clause from being reached (missing/extra comma, unbalanced bracket, etc)
你的括号不平衡我数了 4 左和 5 右。当存在阻止到达 FROM 子句的格式错误(缺少/额外逗号、不平衡括号等)时,通常会发生此错误
回答by Randy
SELECT TITLE, TO_CHAR( SUM( COST-RETAIL )/ SUM( COST )) || '%'
AS "Markup"
FROM BOOKS
GROUP BY TITLE;
回答by Joe W
There was an extra right parentheses and here is what it should look like.
有一个额外的右括号,它应该是这样的。
SELECT TITLE, CONCAT(TO_CHAR(SUM((COST-RETAIL/COST)*100), '100'), '%')
AS "Markup"
FROM BOOKS
GROUP BY TITLE;