Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Odp: Tricky SQL
> table employee:
> employeeid(PK), name, companyid(FK)
>
> table company:
> companyid(PK) , name
>
> table department:
> departmentid(PK) , name, companyid(FK)
>
> · Write a query to list all the department names from all
> companies that (the companies) have more than 25 employees and that
> (the company) have a name that starts with an 'A'.
>
select d.name
from department d, company c
where d.companyid = c.companyid and
substr(c.name, 1, 1) = 'A' and
25 < (select count(*) from employee e where e.companyid = c.companyid);
Received on Thu Nov 23 2000 - 00:25:01 CST
![]() |
![]() |