我们可以从表中选择计数(查询)吗

时间:2019-04-30 08:35:43

标签: sql oracle oracle11g

SELECT COUNT(ANOTHER SELECT QUERY) FROM DUAL.

我们能以这种方式获得结果还是有其他方式?

2 个答案:

答案 0 :(得分:3)

一个例子可以帮助您

SQL> create table tabTest as (select 1 x from dual);

Table created.

SQL> select count( select * from tabTest ) from dual;
select count( select * from tabTest ) from dual
              *
ERROR at line 1:
ORA-00936: missing expression


SQL> select count(*) from (select * from tabTest);

  COUNT(*)
----------
         1

答案 1 :(得分:1)

您可以使用派生表(又名“子查询”)

select count(*)
from (
  .... your query here ...
);