1

I entered this:

SELECT COST TO_CHAR(COALESCE (COST, 0), '$99,990.99') 
  FROM COURSE;
SELECT COST TO_CHAR(NVL(cost, 0), '$99,990.99') COST
  FROM COURSE;

Then I get this message:

SELECT COST TO_CHAR(COALESCE (COST, 0), '$99,990.99')
                   *
ERROR at line 1: 
ORA-00923: FROM keyword not found where expected 
SELECT  COST TO_CHAR(NVL(cost, 0), '$99,990.99') COST
                    *
ERROR at line 1: 
ORA-00923: FROM keyword not found where expected 

I am trying to get the costs of the courses, while in a specific format:

COST
-------------
 $0.00
 $1,000.00

Any help would be appreciated

4

2 回答 2

2

查询应该是这样的:

SELECT  TO_CHAR(COALESCE (COST, 0), '$99,990.99') FROM COURSE;
SELECT  TO_CHAR(NVL(cost, 0), '$99,990.99')  FROM COURSE;

您的 SELECT 语句中有太多COST关键字。

如果要COST在格式化时保留列,请添加逗号,如下所示:

SELECT COST, TO_CHAR(COALESCE (COST, 0), '$99,990.99') COST_FORMATTED FROM COURSE;
SELECT COST, TO_CHAR(NVL(cost, 0), '$99,990.99') COST_FORMATTED FROM COURSE;
于 2013-04-07T18:53:20.053 回答
1

您在第一个之后缺少逗号COST

SELECT COST, TO_CHAR(COALESCE (COST, 0), '$99,990.99') FROM COURSE; 
SELECT COST, TO_CHAR(NVL(cost, 0), '$99,990.99') FROM COURSE;

COST如果您选择从成本开始,则命名第二列是没有意义的。

于 2013-04-07T18:53:58.410 回答