Schema: CREATE TABLE model_list (maker VARCHAR, model VARCHAR); CREATE TABLE countries (countryid VARCHAR, countryname VARCHAR); CREATE TABLE car_makers (country VARCHAR, id VARCHAR)
Question: What are the ids and names of all countries that either have more than 3 car makers or produce fiat model ?
SQL: SELECT t1.countryid, t1.countryname FROM countries AS t1 JOIN car_makers AS t2 ON t1.countryid = t2.country GROUP BY t1.countryid HAVING COUNT(*) > 3 UNION SELECT t1.countryid, t1.countryname FROM countries AS t1 JOIN car_makers AS t2 ON t1.countryid = t2.country JOIN model_list AS t3 ON t2.id = t3.maker WHERE t3.model = 'fiat'