CREATE TABLE student (stuid NUMBER, lname CLOB, fname CLOB, age NUMBER, sex CLOB, major NUMBER, advisor NUMBER, city_code CLOB)
CREATE TABLE lives_in (stuid NUMBER, dormid NUMBER, room_number NUMBER)
CREATE TABLE has_amenity (dormid NUMBER, amenid NUMBER)
CREATE TABLE dorm_amenity (amenid NUMBER, amenity_name CLOB)
CREATE TABLE dorm (dormid NUMBER, dorm_name CLOB, student_capacity NUMBER, gender CLOB)

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