Question: What are the ids, names and genders of the architects who built two bridges or one mill?
Schema: create table mill (architect_id varchar, PRIMARY KEY (architect_id)); create table architect (id varchar, name varchar, gender varchar, PRIMARY KEY (id)); create table bridge (architect_id varchar, PRIMARY KEY (architect_id))
SQL: select t1.id, t1.name, t1.gender from architect as t1 join bridge as t2 on t1.id = t2.architect_id group by t1.id having count(*) = 2 union select t1.id, t1.name, t1.gender from architect as t1 join mill as t2 on t1.id = t2.architect_id group by t1.id having count(*) = 1