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

2 Answers2

2

The queries should be like this:

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

There were too much COST keyword in your SELECT statement.

If you want to keep the COST column while formatting it, add the commas like this:

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;
araknoid
  • 3,065
  • 5
  • 33
  • 35
1

You a lacking a comma after the first 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;

And it doesn't make sense to name the second column COST if you select cost to begin with.