user770022
user770022

Reputation: 2959

What's wrong with this command in SQL plus?

I want to count the number of employees

SQL> select count(ename) AS number of people, from emp;
select count(ename) AS number of people, from emp
                   *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected


SQL>

Here's my table

 SQL> select ename from emp;

 ENAME
 ----------
 KING
 BLAKE
 CLARK
 JONES
 MARTIN
 ALLEN
 TURNER
 JAMES
 WARD
 FORD
 SMITH

 ENAME
 ----------
 SCOTT
 ADAMS
 MILLER

 14 rows selected.

 SQL>

Upvotes: 0

Views: 153

Answers (2)

Bernard Dy
Bernard Dy

Reputation: 1992

The comma after the "people" is probably what's causing the error.

You will also need to use a different alias for the count() column, either by removing the spaces or replacing them with underscores.

Upvotes: 1

Joe
Joe

Reputation: 15802

Remove the comma before the FROM clause. Also, you can't have spaces in field name, use underscores instead.

Also, it's good practice to capitalise keywords:

SELECT COUNT(ename) AS number_of_people FROM emp

Upvotes: 0

Related Questions