Q:

Oracle SQL crazy subqueries across 4 tables

Here are the relations:
CREATE TABLE employee (
  fname    varchar2(15) not null, 
  minit    varchar2(1),
  lname    varchar2(15) not null,
  ssn      char(9),
  bdate    date,
  address  varchar2(30),
  sex      char,
  salary   number(10,2),
  superssn char(9),
  dno      number(4),
  primary key (ssn),
  foreign key (superssn) references employee(ssn),
  foreign key (dno) references department(dnumber)
);

CREATE TABLE department (
  dname        varchar2(15) not null,
  dnumber      number(4),
  mgrssn       char(9) not null, 
  mgrstartdate date,
  primary key (dnumber),
  unique (dname),
  foreign key (mgrssn) references employee(ssn)
);

CREATE TABLE dept_locations (
  dnumber   number(4),
  dlocation varchar2(15), 
  primary key (dnumber,dlocation),
  foreign key (dnumber) references department(dnumber)
);

CREATE TABLE project (
  pname      varchar2(15) not null,
  pnumber    number(4),
  plocation  varchar2(15),
  dnum       number(4) not null,
  primary key (pnumber),
  unique (pname),
  foreign key (dnum) references department(dnumber)
);

CREATE TABLE works_on (
  essn   char(9),
  pno    number(4),
  hours  number(4,1),
  primary key (essn,pno),
  foreign key (essn) references employee(ssn),
  foreign key (pno) references project(pnumber)
);

Q: Find the names and addresses of all employees who work on at least one project located in Houston but whose department has no location in Houston.
Here is my query:
select fname, minit, lname, address
from employee
where dno=
(select dnumber from dept_locations where dlocation<>'Houston' and dnumber=
(select dno from employee where ssn=
(select essn from works_on where pno=
(select pnumber from project where plocation='Houston'))))

But it did not compile and returned this error:
    ORA-01427: single-row subquery returns more than one row

Please help!

A:

select fname, minit, lname, address
from employee
where dno in
(select dnumber from dept_locations where dlocation<>'Houston') and ssn in
(select essn from works_on where pno in
(select pnumber from project where plocation='Houston'))))

