Here is a solution using two levels of subqueries in the WHERE clause:
SELECT e.last_name || ', ' || e.first_name AS "Name", e.phone_number
FROM employees e
WHERE e.employee_id IN (
SELECT i.employee_id
FROM inspections i
WHERE i.location_id IN (
SELECT l.location_id
FROM locations l
WHERE l.city = 'SKOKIE' AND l.state = 'IL'
)
)
To list the license_no, dba_name, and No_inspections for establishments with over 5 inspections:
SELECT l.license_no, l.dba_name, COUNT(i.inspection_id) AS "No_inspections"
FROM locations l
JOIN inspections i ON i.location_id = l.location_id
WHERE i.inspection_date >= '2015-01-01' AND i.inspection_date < '2016-01-01'
GROUP BY l.license_no, l.dba_name
HAVING COUNT(i.inspection_id) > 5
A subquery is used to return data that will be used in the outer SELECT, INSERT, UPDATE, or DELETE statement, or to set a value in the SET clause of an UPDATE statement. Subqueries can be used in various parts of a SQL statement, such as the WHERE clause, the FROM clause, or the SELECT clause.
Learn more about subquery, here https://brainly.com/question/14079843
#SPJ4