Question: Find the first and last name of students who are living in the dorms that have amenity TV Lounge.
Schema: create table has_amenity (dormid varchar, amenid varchar, PRIMARY KEY (dormid)); create table lives_in (stuid varchar, dormid varchar, PRIMARY KEY (stuid)); create table student (fname varchar, lname varchar, stuid varchar, PRIMARY KEY (fname)); create table dorm_amenity (amenid varchar, amenity_name varchar, PRIMARY KEY (amenid))
SQL: 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')