SQL plus 中的这个命令有什么问题?

发布于 12-03 13:49 字数 488 浏览 1 评论 0原文

我想统计员工人数

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>

这是我的表格

 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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

内心激荡2024-12-10 13:50:00

删除 FROM 子句之前的逗号。另外,字段名称中不能有空格,请使用下划线。

此外,将关键字大写也是一个好习惯:

SELECT COUNT(ename) AS number_of_people FROM emp

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
久光2024-12-10 13:49:59

“people”后面的逗号可能是导致错误的原因。

您还需要为 count() 列使用不同的别名,方法是删除空格或用下划线替换它们。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文