I have a project where I have to use nested select and operators like EXISTS, IN, ALL, ANY, to find the name of the owners who own more apartments.
I have the 2 tables owners and apartments
Owner
"ID" NUMBER(5,0),
"NAME" VARCHAR2(20),
"PHONE" NUMBER(10,0),
CONSTRAINT "PROPR" PRIMARY KEY ("ID")
USING INDEX ENABLE;
Apartment
"ID_AP" NUMBER(5,0),
"ADDRESS" VARCHAR2(35),
"SURFACE" NUMBER(10,0),
"ID" NUMBER(5,0),
CONSTRAINT "APART" PRIMARY KEY ("ID_AP")
USING INDEX ENABLE;
In order to find the owners who have more than one apartment, I wrote this
SELECT name, id, count(id)
from apartment join owner
using (id)
group by id, name
having count(id)>1
But how do I use nested Selects and one of the operators EXISTS, IN, ALL, ANY?