我想弄明白为什么我的查询给了我这个错误:
ORA-00907:缺少右括号 00907. 00000 - “缺少右括号” *原因:
*动作:行错误:2列:10
从此代码(已编辑):
SELECT
51,000 AS "Starting Principal",
(51,000 + (51,000 * 0.10)) AS "New Principal",
(.065*(51,000 + (51,000 * 0.10))) AS "Interest",
(51,000 + (51,000 * 0.10)) + (.065*(51,000 + (51,000 * 0.10))) AS "Principal + Interest",
TO_CHAR(SYSDATE,'dd-mon-yyyy hh24:mi:ss') AS "System Date"
FROM Dual
如果这有帮助,我的查询来自我的作业问题:
- 使用Dual表创建包含以下列的行: 启动主要启动原则应等于$ 51,000
醇>新校长 - >起始本金加10%增加
兴趣 - > 6.5%的新校长 本金+利息 - >新主体加上兴趣(将用于新主成分计算的表达式添加到用于计算利息的表达式中)现在,添加一个名为“System Date”的列,该列使用TO_CHAR函数显示SYSDATE函数的>结果,当它以这种格式显示时: 'dd-mon-yyyy hh24:mi:ss' 此格式将显示>系统日期的日,月,年,小时,分钟和秒,这将显示系统日期还包括时间。
请帮忙。
答案 0 :(得分:1)
首先,使用'。'在数字','是一个单词分隔符。接下来,删除';'在声明中间。最后,不要省略'*'。那是
SELECT 51.000 AS "Starting Principal",
(510.00 + (51.000 * 0.10)) AS "New Principal",
(.065 *(51.000 + (51.000 * 0.10))) AS "Interest",
(51.000 + (51.000 * 0.10)) + (.065 *(51.000 + (51.000 * 0.10))) AS "Principal + Interest",
TO_CHAR(SYSDATE,'dd-mon-yyyy hh24:mi:ss') AS "System Date"
FROM Dual;
结果
Starting Principal New Principal Interest Principal + Interest System Date
------------------ ------------- ---------- -------------------- -----------------------------
51 515.1 3.6465 59.7465 11-sep-2016 15:27:42
答案 1 :(得分:0)
删除from子句之前的最后一个分号,如下所示:
SELECT 51000 AS "Starting Principal"
(51000 + (51000 * 0.10)) AS "New Principal"
(.065 * (51000 + (51000 * 0.10))) AS "Interest"
(51000 + (51000 * 0.10)) + (.065 * (51000 + (51000 * 0.10))) AS "Principal + Interest"
TO_CHAR(SYSDATE'dd-mon-yyyy hh24:mi:ss') AS "System Date"
FROM Dual