0

I'm trying to the number of the elements of two tables here is what I've tried :

 select 
((select count(*) from Person,Professor where ID_Person = ID_Professor)  + 
(select count(*) from Person, Student where ID_Person = ID_Student ))

well this doesn't work any Idea how can I do this? thanks in advance

2 Answers 2

1

You're just missing a from dual on the end, to make the outer select a complete statement.

Exactly as you had it plus 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
Sign up to request clarification or add additional context in comments.

1 Comment

thanks for your answer, but honestly I don't get what do you mean ?
1

Wumpus Q. Wumbley has given correct suggestion for Oracle database.

For your question you can try following query as well -

   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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.