我正在尝试两个表的元素数量,这是我尝试过的:
select
((select count(*) from Person,Professor where ID_Person = ID_Professor) +
(select count(*) from Person, Student where ID_Person = ID_Student ))
好吧,这不起作用任何想法我该怎么做?提前致谢
我正在尝试两个表的元素数量,这是我尝试过的:
select
((select count(*) from Person,Professor where ID_Person = ID_Professor) +
(select count(*) from Person, Student where ID_Person = ID_Student ))
好吧,这不起作用任何想法我该怎么做?提前致谢
你只是from dual
在最后遗漏了一个,使外部选择一个完整的语句。
和你一样,加上from dual
:
select
((select count(*) from Person,Professor where ID_Person = ID_Professor) +
(select count(*) from Person, Student where ID_Person = ID_Student ))
from dual
Wumpus Q. Wumbley 对 Oracle 数据库给出了正确的建议。
对于您的问题,您也可以尝试以下查询 -
select sum(c_total)
from (
select (select count(*) from professor
where professor.id_professor=person.id_person)
+ (select count(*) from student
where student.id_student=person.id_person) c_total
from person
group by person.id_person)