CREATE TABLE student (fname VARCHAR2, lname VARCHAR2, stuid VARCHAR2)
CREATE TABLE dorm_amenity (amenid VARCHAR2, amenity_name VARCHAR2)
CREATE TABLE lives_in (stuid VARCHAR2, dormid VARCHAR2)
CREATE TABLE has_amenity (dormid VARCHAR2, amenid VARCHAR2)

Find the first and last name of students who are living in the dorms that have amenity TV Lounge.
SELECT T1.fname, T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
WITH "_u_0" AS (SELECT "T3"."dormid" FROM "has_amenity" "T3" JOIN "dorm_amenity" "T4" ON "T3"."amenid" = "T4"."amenid" AND "T4"."amenity_name" = 'TV Lounge' GROUP BY "dormid") SELECT "T1"."fname", "T1"."lname" FROM "student" "T1" JOIN "lives_in" "T2" ON "T1"."stuid" = "T2"."stuid" LEFT JOIN "_u_0" "_u_0" ON "T2"."dormid" = "_u_0"."" WHERE NOT "_u_0"."" IS NULL