Question: What starting years and player IDs from the player_coach table are common to records that meet both of these criteria: (1) either the player ID is less than 10, or the starting year is 2010 or later and the coach ID is greater than 1; and (2) either the player ID is not 1 and the coach ID is 1 or less, or the starting year is after 2013?

SELECT Starting_year, Player_ID FROM player_coach WHERE "Player_ID" < 10 OR "Starting_year" >= 2010 AND "Coach_ID" > 1 INTERSECT SELECT Starting_year, Player_ID FROM player_coach WHERE "Player_ID" != 1 AND "Coach_ID" <= 1 OR "Starting_year" > 2013


Question: What are the maximum head ID, age, earliest name, and born state for people who are either under ID 9 and 68 years old, or not from Florida, or named 'K. J. Choi', but not if their ID is 3 or less?

SELECT MAX(head_ID), age, MIN(name), born_state FROM head WHERE "head_ID" < 9 AND "age" = 68.0 OR born_state <> "Florida" OR name = "K. J. Choi" EXCEPT SELECT MAX(head_ID), age, MIN(name), born_state FROM head WHERE "head_ID" <= 3


Question: What driver ID is both driver number 9 and also a school bus driver with ID 3 or more?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 9 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 3


Question: What is the highest number of issues for books not published by Pearson, and which publisher is associated with a book having that many issues?

SELECT MAX(T1.Issues), T2.Publisher FROM book as T1 JOIN publication as T2 ON T1.Book_ID = T2.Book_ID WHERE Publisher <> "Pearson"


Question: What Aircraft IDs are present in both the aircraft and airport_aircraft lists, excluding ID 3 and only considering IDs less than 5?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 3 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 5


Question: What driver IDs are either greater than 8 or at most 4?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 8 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 4


Question: What driver IDs are either greater than 11 in the driver table or equal to 3 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 11 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 3


Question: What driver IDs are 5 or greater, but are not among the school bus driver IDs that are less than 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: What are the Store IDs that are either greater than 4 in district stores, or less than 5 and not for product 2 in product stores?

SELECT Store_ID FROM store_district WHERE "Store_ID" > 4 UNION ALL SELECT Store_ID FROM store_product WHERE "Store_ID" < 5 AND "Product_ID" != 2


Question: What Driver IDs are number 2 in the driver list but not greater than 3 in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 2 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 3


Question: What are the driver IDs that are less than 7 from the drivers or less than 4 from the school bus drivers?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 7 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 4


Question: What are the Driver IDs that are at least 1, or are greater than 4 for school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 1 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 4


Question: What is a store ID and the highest product ID for product ID 2, and also, what is a store ID and the highest product ID for stores with ID 1 or greater?

SELECT Store_ID, MAX(Product_ID) FROM store_product WHERE "Product_ID" = 2 UNION ALL SELECT Store_ID, MAX(Product_ID) FROM store_product WHERE "Store_ID" >= 1


Question: Find the driver IDs that are less than 3, but exclude any driver IDs that are greater than 10 in the school bus records.

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 3 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 10


Question: What are the rank, club ID, coach ID, and coach name of coaches who are either not male, or not ranked 1, or have a coach ID greater than 5, or are ranked 2, or are not named 'Smith Brown'?

SELECT Rank, Club_ID, Coach_ID, Coach_name FROM coach WHERE Gender <> "M" OR "Rank" != 1 OR "Coach_ID" > 5 UNION ALL SELECT Rank, Club_ID, Coach_ID, Coach_name FROM coach WHERE "Rank" = 2 OR Coach_name != "Smith Brown" OR Gender != "M"


Question: Which driver IDs are 8 or greater and are drivers but not school bus drivers?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 4


Question: What are the driver IDs that are both not equal to 6 and greater than 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 6 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 9


Question: Which aircraft IDs are at least 2 in the aircraft table, but are not greater than 2 in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 2


Question: Which Aircraft IDs are in the aircraft table with an ID of 4 or more and also in the airport_aircraft table with an ID of 5 or less?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 4 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 5


Question: What driver IDs, other than 4, are in the driver table but not among driver IDs 1 to 4 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 4 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 4


Question: What driver IDs are 6 or greater, but are not also driver IDs less than 10 in the school bus records?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 6 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: What are the address details for addresses with an ID of 6 or less, excluding 'IE', and also for address ID 9?

SELECT address_details FROM Addresses WHERE "address_id" <= 6 AND address_details != "IE" UNION ALL SELECT address_details FROM Addresses WHERE "address_id" = 9


Question: Which driver ID is number 2 and is a driver but not a school bus driver?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 2 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 7


Question: What driver IDs are greater than 5 but are not also driver IDs less than or equal to 9 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 9


Question: Which driver IDs are 4 or greater in the driver list, but not 4 or less in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 4 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 4


Question: Give me the driver IDs that are greater than 5 from the driver list, excluding any driver IDs that are 10 or more from the school bus list.

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 10


Question: What are the unique Aircraft IDs that are less than or equal to 1 from the aircraft table, or not equal to 1 from the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 1 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 1


Question: What are the driver IDs that are both less than 7 and not equal to 9, and are found in both the driver and school bus records?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 7 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 9


Question: What are the document IDs of documents that are not papers or are draft copies with copy number 10?

SELECT document_id FROM Documents WHERE document_type_code <> "Paper" UNION ALL SELECT document_id FROM Draft_Copies WHERE "copy_number" = 10


Question: What driver IDs are both drivers, excluding driver 6, and school bus drivers with IDs up to 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 6 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: What driver IDs are not 10 from the driver table, or are 4 or greater from the school_bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 10 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 4


Question: What driver IDs are on both the driver list and the school bus list and are 4 or less?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 12 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 4


Question: Give me a list of driver IDs that are 4 or greater from the driver table, along with driver ID 9 from the school bus table.

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 4 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 9


Question: What driver IDs are drivers, excluding driver 3, but not school bus drivers with IDs less than 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 3 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 9


Question: Which driver IDs are less than 6 from the drivers, and not among the driver IDs greater than 10 in the school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 6 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 10


Question: What are the Driver IDs that are both not equal to 2 and also less than or equal to 3?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 2 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 3


Question: What are the genders and ranks of coaches who are either male, or not from club 3, not named Joe Fabbri, and have a Coach ID of 3 or greater, except for any genders and ranks that are also found among players living in Winnipeg?

SELECT Gender, Rank FROM coach WHERE "Club_ID" != 3 AND Coach_name != "Joe Fabbri" AND "Coach_ID" >= 3 OR Gender = "M" EXCEPT SELECT Gender, Rank FROM player WHERE Residence = "Winnipeg"


Question: What are driver ID number 5, and all school bus driver IDs up to number 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 5 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 9


Question: What driver IDs are on both the driver list and the school bus list, excluding ID 7 and including only IDs up to 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 7 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: Which driver IDs are either less than 11 from the driver table or not equal to 3 from the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 11 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


Question: What driver IDs are drivers, other than 8, but not school bus drivers, other than 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: Can you tell me driver ID 2 from the driver list, and also all driver IDs that are not 7 from the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 2 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 7


Question: Which driver IDs are either not 4 in the driver table, or are less than 3 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 4 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 3


Question: What are the company IDs of companies that are headquartered in the USA, or that have employees with more than 4 years of employment?

SELECT Company_ID FROM company WHERE Headquarters = "USA" UNION ALL SELECT Company_ID FROM employment WHERE "Year_working" > 4


Question: What are the unique Aircraft IDs that are 5 or greater from the aircraft table, or not equal to 3 from the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 5 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 3


Question: Which driver IDs are in both the driver list (excluding driver 6) and the school bus list (for driver IDs 3 or less)?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 6 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 3


Question: Which Aircraft IDs, that are 4 or higher, are listed in both the aircraft and airport_aircraft tables?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 4 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 3


Question: Can you list the incorporation location and ID, along with the total of 'Type', the alphabetically first 'name', the lowest 'Group Equity Shareholding', and the total of 'Principal Activities', for companies from the 'operate_company' table that satisfy either of these sets of criteria: (1) companies not incorporated in Hong Kong, or (not ID 11 and equity shareholding over 100), or (named 'VN/CX Catering Services Limited' and 'Joint Venture'), or (principal activity not 'Laundry'); OR (2) companies with (ID 10 or less and 100% equity shareholding), or ('Joint Venture'), or (not named 'Cathay Pacific Holidays'), or (principal activity not 'Airline'), or (not incorporated in Hong Kong)? Please combine all results into one list.

SELECT Incorporated_in, id, SUM(Type), MIN(name), MIN(Group_Equity_Shareholding), SUM(Principal_activities) FROM operate_company WHERE Incorporated_in != "Hong Kong" OR "id" != 11 AND "Group_Equity_Shareholding" > 100.0 OR name = "VN/CX Catering Services Limited" AND Type = "Joint Venture" OR Principal_activities != "Laundry" UNION ALL SELECT Incorporated_in, id, SUM(Type), MIN(name), MIN(Group_Equity_Shareholding), SUM(Principal_activities) FROM operate_company WHERE "id" <= 10 AND "Group_Equity_Shareholding" = 100.0 OR Type = "Joint Venture" OR name <> "Cathay Pacific Holidays" OR Principal_activities != "Airline" OR Incorporated_in <> "Hong Kong"


Question: What are the average start dates for each shop, both for employees who are not employee 2, or are full-time, or are not in shop 4, or did not start in 2009, and also for part-time employees?

SELECT AVG(Start_from), Shop_ID FROM hiring WHERE "Employee_ID" != 2 OR Is_full_time = "T" OR "Shop_ID" != 4 OR Start_from != "2009" UNION ALL SELECT AVG(Start_from), Shop_ID FROM hiring WHERE Is_full_time <> "T"


Question: What driver IDs are shared between drivers who are not driver 3 and school bus drivers who are not driver 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 3 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 9


Question: What aircraft IDs, other than 3, are listed in the aircraft table but not in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 3 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 3


Question: What are the total 'Committee', 'Delegate', 'Counties Represented', total 'Election ID', and 'District' for elections first held outside 1994, excluding those that also meet a specific set of conditions on election details?

SELECT SUM(Committee), Delegate, Counties_Represented, SUM(Election_ID), District FROM election WHERE "First_Elected" != 1994.0 EXCEPT SELECT SUM(Committee), Delegate, Counties_Represented, SUM(Election_ID), District FROM election WHERE "Election_ID" <> 6 OR "Party" <> 1 AND Delegate <> "Miller, Warren E. Warren E. Miller" AND Committee = "Appropriations" OR "District" > 1 OR "First_Elected" = 1994.0 AND Counties_Represented <> "13"


Question: What driver IDs are less than 7 in the driver table but are not driver IDs of 9 or greater in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 7 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


Question: What driver IDs are 8 or less in the driver table, but not also 4 or less in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 4


Question: What are the County IDs for counties that either have an ID of 3 or more, or a zip code other than 'D08', or are not named 'Howard' and have a population different from 90000, or have a population of 79000 or more?

SELECT County_Id FROM county WHERE "County_Id" >= 3 OR Zip_code <> "D08" OR County_name != "Howard" AND "Population" <> 90000.0 UNION ALL SELECT County_Id FROM county WHERE "Population" >= 79000.0


Question: What driver IDs are both greater than 5 and not equal to 3, considering drivers and school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 5 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


Question: What driver IDs are for drivers other than driver 4, and are not school bus drivers with IDs 10 or less?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 4 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: What are the driver IDs that are not 12 from the drivers, and driver IDs that are 3 or less from the school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 12 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 3


Question: What are the driver IDs that are drivers, but not driver ID 11, and also not driver ID 9 if driver ID 9 is a school bus driver?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 11 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 9


Question: What driver IDs are in both the driver list, excluding driver 8, and the school bus driver list, excluding driver 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 8 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 10


Question: What are the driver IDs of drivers who are not driver 3, and who are not also school bus drivers?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 3 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 4


Question: What is the highest vehicle detail and the number of vehicles that are trucks and have vehicle ID 1, as well as for vehicles with vehicle IDs greater than 1?

SELECT MAX(vehicle_details), COUNT(vehicle_id) FROM Vehicles WHERE vehicle_details = "Truck" AND "vehicle_id" = 1 UNION ALL SELECT MAX(vehicle_details), COUNT(vehicle_id) FROM Vehicles WHERE "vehicle_id" > 1


Question: What driver IDs are drivers, except for driver 12, but are not school bus drivers?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 12 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: What driver IDs, greater than or equal to 9, excluding 10, are in both the driver and school bus lists?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 10 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


Question: What are the average market values for industries that meet either of two different sets of company financial conditions?

SELECT AVG(Market_Value_in_Billion), Industry FROM company WHERE Name <> "Volkswagen Group" AND "Company_ID" >= 19.0 OR "Profits_in_Billion" <= 31.7 OR "Sales_in_Billion" <> 82.6 AND "Assets_in_Billion" >= 209.5 GROUP BY Industry HAVING AVG(Market_Value_in_Billion) >= 79.5 UNION SELECT AVG(Market_Value_in_Billion), Industry FROM company WHERE Industry = "Banking" OR "Company_ID" != 2.0 OR Name <> "ExxonMobil" OR "Market_Value_in_Billion" <> 202.2 OR "Profits_in_Billion" != 10.3 AND "Assets_in_Billion" >= 328.7 AND "Sales_in_Billion" > 433.5 GROUP BY Industry HAVING AVG(Market_Value_in_Billion) <= 208.4


Question: What are the IDs of albums other than 'Live On Two Legs live' and also the IDs of genres that are 'Metal'?

SELECT id FROM albums WHERE title <> "Live On Two Legs live" UNION ALL SELECT id FROM genres WHERE name = "Metal"


Question: What customer IDs, other than 11, are in the payment records but are not also associated with customers who either owe less than 1000 and have mobile number '00659133944', or have a different email address from 'myrl.lind@example.net'?

SELECT customer_id FROM Customer_Payments WHERE "customer_id" <> 11 EXCEPT SELECT customer_id FROM Customers WHERE "amount_outstanding" < 1000.0 AND cell_mobile_phone_number = "00659133944" OR email_address <> "myrl.lind@example.net"


Question: What driver IDs are common to drivers with IDs less than 8 and school bus drivers with IDs 7 or more?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 8 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 7


Question: What are the IDs of albums that are either by artists with ID 271 or higher and have an ID of 226 or higher, or are not titled 'Raul Seixas', together with the IDs of genres that are numbered below 22?

SELECT id FROM albums WHERE "artist_id" >= 271 AND "id" >= 226 OR title != "Raul Seixas" UNION SELECT id FROM genres WHERE "id" < 22


Question: What aircraft IDs are in the aircraft table and are 2 or greater, but are not 3 in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 3


Question: What Aircraft IDs are either greater than 5, or not equal to 2, considering information from both aircraft and airport aircraft?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 5 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 2


Question: Which Driver IDs are in the driver table and are greater than 2, and also in the school_bus table and are equal to 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 2 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 10


Question: What is the total sum of IDs, combining the sum from car makers excluding those with ID 22 or 'Kia Motors', and the sum from car data for cars that either have an engine displacement of 168 or more and an ID greater than 371, or are from 1981, weigh 2979 or more, don't accelerate at 16, have more than 6 cylinders, and have 150 horsepower?

SELECT SUM(Id) FROM car_makers WHERE "Id" <> 22 OR FullName <> "Kia Motors" UNION SELECT SUM(Id) FROM cars_data WHERE "Edispl" >= 168.0 AND "Id" > 371 OR "Year" = 1981 AND "Weight" >= 2979 AND "Accelerate" != 16.0 AND "Cylinders" > 6 AND Horsepower = "150"


Question: What are the aircraft IDs that are either not equal to 2 from the aircraft table or less than or equal to 5 from the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 5


Question: What are the document IDs for document drafts that are not 'w' and for documents that are not document number 2?

SELECT document_id FROM Document_Drafts WHERE draft_details != "w" UNION SELECT document_id FROM Documents WHERE "document_id" != 2


Question: Which driver IDs are greater than 6, but not also 10 or greater in the school bus driver list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 6 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 10


Question: Does student 1026 have a grass pollen allergy?

SELECT Allergy FROM Allergy_Type WHERE Allergy = "Grass Pollen" INTERSECT SELECT Allergy FROM Has_Allergy WHERE "StuID" = 1026


Question: What are the feature type codes, excluding 'Security' types with feature IDs greater than 4 from available features, and excluding 'Security, eg Burglar Alarm.' types from reference feature types?

SELECT feature_type_code FROM Other_Available_Features WHERE feature_type_code <> "Security" AND "feature_id" > 4 UNION ALL SELECT feature_type_code FROM Ref_Feature_Types WHERE feature_type_name <> "Securiyt, eg Burglar Alarm."


Question: What driver IDs are number 1, but not also school bus driver IDs of 4 or greater?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 1 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 4


Question: Which driver IDs are in the driver table, except for driver ID 9, and are not also listed in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 9 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: Which aircraft IDs, other than 2, are in the aircraft or airport aircraft tables?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 2


Question: What driver IDs are not 12 from the driver list or less than 7 from the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 12 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 7


Question: What driver IDs are less than 12, excluding those that are also greater than 3 and associated with school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 12 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 3


Question: What driver IDs are either greater than 11, or are driver IDs less than 4 from the school_bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 11 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 4


Question: What are the Aircraft IDs that are 1 or less from the aircraft table, or not equal to 3 from the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 1 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 3


Question: What are the driver IDs that are greater than 7 in the driver table, or less than or equal to 9 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 7 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 9


Question: What are the role codes for employees who are not part-time, as well as the role codes from the Roles table that are not 'PR' and are not for Editors?

SELECT role_code FROM Employees WHERE role_code <> "PT" UNION ALL SELECT role_code FROM Roles WHERE role_code != "PR" AND role_description != "Editor"


Question: Which driver IDs are 7 or below from the drivers, and also driver ID 10 from the school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 7 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 10


Question: What Aircraft IDs are common to both the aircraft and airport_aircraft lists, considering only aircraft IDs of 3 or more and 5 or less respectively?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 3 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 5


Question: What driver IDs are drivers but not school bus drivers, excluding driver ID 2 and driver ID 7 from the respective lists?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 2 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 7


Question: What Aircraft IDs are either greater than 5 or not equal to 1

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 5 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 1


Question: What driver IDs are both not 4 and also 9 or greater?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 4 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


Question: What aircraft IDs are in both the aircraft and airport aircraft lists, and are 3 or greater, but not 5?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 5 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 3


Question: What aircraft IDs, other than 4, are in the aircraft table but not in the airport_aircraft table, if we ignore ID 1 in that table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 4 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 1


Question: What driver IDs are both less than 11 and not equal to 3, and appear in both the driver and school bus lists?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 11 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 3


Question: Could you list the zip code, building number, state, city, address ID, and country for addresses that are either not in Kentucky, or in the USA, or have zip code 95098, or have an address ID less than 4, or are not in Lake Rafaela, or have a building number other than '9260 Streich Mountain', or are in the USA and have zip code 27559?

5
484 O'Hara Drive
Oregon
Buckridgehaven
4
USA

8938
00704 Zoe Alley
Georgia
Lake Elaina
3
USA

14445
3904 Stroman Passage
Georgia
Port Melyssa
1
USA

22194
053 Quigley Island
Kentucky
Hagenesfurt
2
USA

27559
354 Frederik Ridge
Ohio
Powlowskichester
5
USA

34975
56461 Baumbach Well Suite 634
Washington
Lockmanfurt
7
USA

38197
7089 Mueller Forks
Louisiana
New Bernieceburgh
12
USA

43988
9260 Streich Mountain
Kentucky
West Edmondview
15
USA

61121
4834 Schaefer Light Suite 947
Connecticut
Damianfort
14
USA

63768
376 Kallie Tunnel Apt. 784
Connecticut
Elviebury
6
USA

75074
43235 Jazmin Mountain Suite 251
Louisiana
Ericamouth
13
USA

80376
29085 Dejah Pine Suite 059
WestVirginia
Lake Rafaela
8
USA

85954
535 Ariel Brook
Maine
Port Jackelinemouth
9
USA

95098
2291 Larkin Ports
Idaho
South Richieport
10
USA

99903
37698 Hahn Curve Apt. 572
Alabama
South Eugene
11
USA

SELECT zip_postcode, line_1_number_building, state_province_county, city, address_id, country FROM Addresses WHERE state_province_county != "Kentucky" OR country = "USA" OR zip_postcode = "95098" OR "address_id" < 4 OR city <> "Lake Rafaela" OR line_1_number_building <> "9260 Streich Mountain" UNION SELECT zip_postcode, line_1_number_building, state_province_county, city, address_id, country FROM Addresses WHERE country = "USA" AND zip_postcode = "27559"


Question: What driver ID do drivers with ID 11 or less and school bus drivers with ID 3 have in common?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 11 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 3


Question: Which driver IDs, less than 11, are drivers but not school bus drivers (ignoring school bus driver 10)?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 11 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: Could you list the type, number of product categories, count of rankings, average store ID, area size, and store name for stores that meet either of these criteria: a ranking of 9 or higher, a store ID of 4 or lower, or less than 990 product categories; OR an area size less than 179.84, exactly 990 product categories, a ranking not equal to 10, or a store ID of 4?

SELECT Type, Number_of_product_category, COUNT(Ranking), AVG(Store_ID), Area_size, Store_Name FROM store WHERE "Ranking" >= 9 OR "Store_ID" <= 4 OR "Number_of_product_category" < 990.0 UNION ALL SELECT Type, Number_of_product_category, COUNT(Ranking), AVG(Store_ID), Area_size, Store_Name FROM store WHERE "Area_size" < 179.84 OR "Number_of_product_category" = 990.0 OR "Ranking" <> 10 OR "Store_ID" = 4


Question: What driver IDs are both in the list of all drivers, excluding driver 4, and in the list of school bus drivers, including only driver 4 and above?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 4 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 4


Question: Find driver ID 6 from the drivers and all driver IDs except 7 from the school buses.

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 6 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 7


Question: Is driver ID 5 a driver but not a school bus driver?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 9


Question: For draft copies, what are the document IDs and draft numbers where the draft number is greater than 9 or the copy number is 10, excluding those with a document ID of 2 or less?

SELECT document_id, draft_number FROM Draft_Copies WHERE "draft_number" > 9 OR "copy_number" = 10 EXCEPT SELECT document_id, draft_number FROM Draft_Copies WHERE "document_id" <= 2


Question: What are the Aircraft IDs, including those from the aircraft table except for ID 4, and those from the airport_aircraft table that are ID 1 or higher?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 4 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 1


Question: What Aircraft IDs are less than 3 in the aircraft table, or less than or equal to 3 in the airport_aircraft table, and show each ID only once?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 3 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 3


Question: What aircraft IDs are in the aircraft list with an ID of 5 or less, but are not in the airport aircraft list with an ID less than 5?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 5 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 5


Question: Which driver IDs are both greater than 7 and not 9, considering drivers and school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 7 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 9


Question: What driver IDs are 6 or less, and not also 3 or greater in the school bus records?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 6 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 3


Question: What is the minimum number of issues for books that either have a Book ID greater than 3 and are not named 'Gemini Blood', or have 9 or fewer issues, unless that number is also the minimum number of issues for books that are either not named 'Michael Moorcock's Multiverse' and have a Book ID over 6 and at most 4 issues, or are not by Garth Ennis?

SELECT MIN(Issues) FROM book WHERE "Book_ID" > 3 AND Title <> "Gemini Blood" OR "Issues" <= 9.0 NOT IN (SELECT MIN(Issues) FROM book WHERE Title <> "Michael Moorcock's Multiverse" AND "Book_ID" > 6 AND "Issues" <= 4.0 OR Writer != "Garth Ennis")


Question: What are the minimum name, maximum distance, and average aid for aircraft, combining two sets of results: one for aircraft with aid not equal to 9, and another for aircraft where the name is not 'Embraer ERJ-145' or aid is less than or equal to 16 and distance is greater than 1504?

SELECT MIN(name), MAX(distance), AVG(aid) FROM aircraft WHERE "aid" != 9 UNION SELECT MIN(name), MAX(distance), AVG(aid) FROM aircraft WHERE name <> "Embraer ERJ-145" OR "aid" <= 16 AND "distance" > 1504


Question: What are the school IDs for schools that are either Trojans in 50 Marshall county or have budget information from any year except 2005?

SELECT School_id FROM School WHERE Mascot = "Trojans" AND County = "50 Marshall" UNION ALL SELECT School_id FROM budget WHERE "Year" <> 2005


Question: What are the unique Aircraft IDs that are not 4 from the aircraft table, or are greater than 1 from the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 4 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 1


Question: Which driver IDs are greater than 6 in the driver list but not in the school bus driver list if they are 9 or greater?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 6 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


Question: Which Driver IDs are greater than 3 in the driver table and less than 3 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 3 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 3


Question: What are the average country values for car makers in two groups: first, those from country '8' with ID up to 7, or named 'Opel', and second, those not from country '3', or with ID greater than 1 and named 'Saab'?

SELECT AVG(Country) FROM car_makers WHERE Country = "8" AND "Id" <= 7 OR FullName = "Opel" UNION SELECT AVG(Country) FROM car_makers WHERE Country <> "3" OR "Id" > 1 AND FullName = "Saab"


Question: What are the average copy number, highest draft number, and total document ID from the circulation history, both for entries with a draft number greater than 17, and also for entries with a document ID less than 10 or an employee ID greater than 1?

SELECT AVG(copy_number), MAX(draft_number), SUM(document_id) FROM Circulation_History WHERE "draft_number" > 17 UNION ALL SELECT AVG(copy_number), MAX(draft_number), SUM(document_id) FROM Circulation_History WHERE "document_id" < 10 OR "employee_id" > 1


Question: What are the average names for aircraft with distances of 520 or more, and also for employees with IDs of 619023588 or more, or named Michael Miller?

SELECT AVG(name) FROM aircraft WHERE "distance" >= 520 UNION ALL SELECT AVG(name) FROM employee WHERE "eid" >= 619023588 OR name = "Michael Miller"


Question: Which driver IDs are in the driver list, excluding driver ID 12, and also excluding driver ID 7 if driver ID 7 is associated with a school bus?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 12 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 7


Question: What driver IDs are either 8 or greater from the driver list or 10 or less from the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 8 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: What driver IDs less than 12 are drivers, excluding driver ID 3 if driver ID 3 is a school bus driver?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 12 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 3


Question: What are the Aircraft IDs, including those that are not 5 from the aircraft table, and those that are 5 or less from the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 5 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 5


Question: What are the school IDs of schools that have 620 students enrolled, but do not have endowments with an ID of 7 or higher, or endowments from 'San José de Ocoa' with a school ID of 7 or higher and an amount not equal to 8.53?

SELECT School_id FROM School WHERE "Enrollment" = 620 EXCEPT SELECT School_id FROM endowment WHERE "endowment_id" >= 7 OR donator_name = "San José de Ocoa" AND "School_id" >= 7 AND "amount" <> 8.53


Question: What driver IDs are 9 or greater in the driver table, but are not driver ID 10 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 9 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 10


Question: Which driver IDs, numbered 8 or less, are drivers but not school bus drivers with IDs less than 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: Which Driver IDs are either greater than 5 in the driver list or less than or equal to 10 in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 5 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: For each creation time, what is the sum of area codes and a phone number for votes, excluding those created on '2018-03-09 19:03:21', and only considering groups with a vote ID of 5 or less and a contestant number of 3 or more?

SELECT SUM(T1.area_code), T2.phone_number FROM AREA_CODE_STATE as T1 JOIN VOTES as T2 ON T1.state = T2.state WHERE created <> "2018-03-09 19:03:21" GROUP BY created HAVING vote_id <= 5 AND contestant_number >= 3


Question: What are the feature IDs of 'AirCon' amenities, excluding those described as 'Air Conditioning', from the 'Other Available Features' list, and also feature IDs greater than 3, excluding those described as 'hic', from the 'Other Property Features' list?

SELECT feature_id FROM Other_Available_Features WHERE feature_description != "Air Conditioning." AND feature_name = "AirCon" AND feature_type_code = "Amenity" UNION ALL SELECT feature_id FROM Other_Property_Features WHERE property_feature_description != "hic" AND "feature_id" > 3


Question: Which Driver IDs are in both the driver and school bus records and are between 8 and 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 8 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: What driver IDs are not 9, or are 3 or greater from school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 9 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 3


Question: What driver IDs are both at least 1 and not equal to 9, and are recorded as both a driver and a school bus driver?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 1 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 9


Question: What are the aircraft IDs that are in both the aircraft table (with IDs of 2 or greater) and the airport_aircraft table (with IDs of 3 or greater)?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 3


Question: Which driver IDs, other than 7, are drivers but not school bus drivers with IDs 4 or less?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 7 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 4


Question: What are the driver IDs that are not 3 or 10 from the driver and school bus records?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 3 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 10


Question: What Aircraft IDs are either 1 or 2?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 2


Question: What driver IDs are in both the drivers list (excluding driver 10) and the school bus drivers list (under ID 10)?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 10 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: What Driver IDs are both 3 or greater and less than 10, and are listed as both drivers and school bus drivers?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 3 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: What driver IDs are less than 5 but are not also driver IDs greater than 3 in the school bus records?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 3


Question: What are the Driver IDs that are not 9 from the driver table, or are greater than 9 from the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 9 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 9


Question: What driver IDs are 11 or less from the driver list, or 4 or less from the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 11 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 4


Question: What Driver IDs are at least 6 in the driver table, or more than 7 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 6 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 7


Question: What is the count of clubs outside the UK, with ID greater than 3, and started in 2005, and also the count of coaches who are not rank 5, not club ID 1, and are either female or named Smith Brown?

SELECT COUNT(Club_ID) FROM club WHERE Region <> "UK" AND "Club_ID" > 3 AND "Start_year" = 2005 UNION SELECT COUNT(Club_ID) FROM coach WHERE "Rank" != 5 AND "Club_ID" != 1 AND Gender = "F" OR Coach_name = "Smith Brown"


Question: What are the driver IDs that are both in the driver list with IDs up to 4, and in the school bus driver list excluding ID 4?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 4 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 4


Question: Can you give me the cell phone number, date of birth, first name, and amount outstanding for customers who either were not registered as a customer on May 13, 2016 around 7:38 AM and are not named Amya, or have an outstanding amount of 9500 or more; or are not named Clara, or their customer status is not 'Good Customer' and they were registered around 5 PM on May 11, 2016 and their birth date is not around 11:11 AM on July 9, 1993, or their customer ID is not 4, or their phone number is not '+14(5)2351480248', or their last name is not Terry and their outstanding amount is not 2255, or their email is not 'karina.carroll@example.net', or their customer address ID is 10 or higher?

SELECT cell_mobile_phone_number, date_of_birth, first_name, amount_outstanding FROM Customers WHERE date_became_customer != "2016-05-13 07:38:23" AND first_name <> "Amya" OR "amount_outstanding" >= 9500.0 UNION SELECT cell_mobile_phone_number, date_of_birth, first_name, amount_outstanding FROM Customers WHERE first_name <> "Clara" OR customer_status_code <> "Good Customer" AND date_became_customer = "2016-05-11 17:03:48" AND date_of_birth <> "1993-07-09 11:11:36" OR "customer_id" <> 4 AND phone_number != "+14(5)2351480248" OR last_name <> "Terry" AND "amount_outstanding" <> 2255.0 OR email_address != "karina.carroll@example.net" OR "customer_address_id" >= 10


Question: What are the driver IDs, including all except 2, plus driver ID 9 from school bus drivers?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 2 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 9


Question: What are the Driver IDs that are not 3 in the driver table, and those greater than 3 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 3 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 3


Question: What are the IDs of all car makers, except for ID 19, combined with the IDs of all cars where the acceleration is not 13.7?

SELECT Id FROM car_makers WHERE "Id" != 19 UNION SELECT Id FROM cars_data WHERE "Accelerate" != 13.7


Question: What is the description for the 'working' document status?

SELECT document_status_code, document_status_description FROM Ref_Document_Status WHERE document_status_code = "working" EXCEPT SELECT document_status_code, document_status_description FROM Ref_Document_Status WHERE document_status_code <> "working"


Question: What are the names and contestant numbers of contestants named Nita Coster with a contestant number between 6 and 10?

SELECT contestant_number, contestant_name FROM CONTESTANTS WHERE "contestant_number" >= 6 OR contestant_name != "Nita Coster" EXCEPT SELECT contestant_number, contestant_name FROM CONTESTANTS WHERE contestant_name != "Nita Coster" OR "contestant_number" > 10


Question: What are the unique Aircraft IDs that are either less than 4 in the aircraft table or less than 2 in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 4 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 2


Question: What driver IDs are common to both drivers with IDs 12 or less and school bus drivers not ID 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 12 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 9


Question: What are the document status codes and descriptions for statuses that are currently working on but are not marked as done?

SELECT document_status_code, document_status_description FROM Ref_Document_Status WHERE document_status_description != "currently working on" OR document_status_code <> "done" EXCEPT SELECT document_status_code, document_status_description FROM Ref_Document_Status WHERE document_status_description != "currently working on"


Question: What Aircraft IDs, greater than 4, are found in both the aircraft and airport_aircraft tables, excluding ID 1 from the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 4 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 1


Question: What Aircraft IDs are either 2 or greater in the aircraft table, or 3 or less in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 3


Question: What driver IDs are less than 5 but are not also driver IDs greater than 7 in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 7


Question: Could you list the member IDs and the number of cards for members who meet either of these conditions: they are not level 6 and not from Simpsonville, South Carolina, or they are not named Corey Peters and not member ID 9, or their level is less than 6 or their name is not Myron Pryor?

SELECT Member_ID, COUNT(Card_Number) FROM member WHERE "Level" <> 6 AND Hometown != "Simpsonville, South Carolina" OR Name <> "Corey Peters" AND "Member_ID" != 9 UNION SELECT Member_ID, COUNT(Card_Number) FROM member WHERE "Level" < 6 OR Name != "Myron Pryor"


Question: What aircraft ID is number 5 in the aircraft table and also listed as number 5 or less in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 5 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 5


Question: What are the document IDs for documents with 'y' in other details, as well as for draft copies with a draft number less than 9 and not document ID 2, or with a copy number less than 10?

SELECT document_id FROM Documents WHERE other_details = "y" UNION ALL SELECT document_id FROM Draft_Copies WHERE "draft_number" < 9 AND "document_id" != 2 OR "copy_number" < 10


Question: What driver IDs are in both the driver and school bus lists and are 7 or less?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 7 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: Which driver IDs are both not driver 6 and also driver IDs of school buses up to 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 6 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: What draft numbers and document IDs are associated with both drafts that are not marked as 'r' and draft copies that are either not from document 1 and are draft number less than 17, or have a copy number of 4 or more?

SELECT draft_number, document_id FROM Document_Drafts WHERE draft_details != "r" INTERSECT SELECT draft_number, document_id FROM Draft_Copies WHERE "document_id" <> 1 AND "draft_number" < 17 OR "copy_number" >= 4


Question: Show me the average item ID for each review rank, considering only reviews and items where user ID is greater than 2, or rank is less than 3, or author ID is greater than 1, or title is 'comb', or rating is 6 or less. Also, only include review ranks where author ID is not 5, or both user ID is 2 or less and title is not 'pear'.

SELECT AVG(T1.i_id), T2.rank FROM item as T1 JOIN review as T2 ON T1.i_id = T2.i_id WHERE "u_id" > 2 OR "rank" < 3 OR "a_id" > 1 OR title = "comb" OR "rating" <= 6 GROUP BY rank HAVING a_id <> 5 OR u_id <= 2 AND title <> "pear"


Question: Could you list the other details and document IDs for documents that are either (document ID is less than 16514113, document name is not 'A history of Arts', and document description is 'n') or (other details are not 'None' and template ID is not 22), and also for paragraphs that are either (paragraph ID is less than 243399026 and document ID is greater than 50123) or (other details are 'None')?

SELECT Other_Details, Document_ID FROM Documents WHERE "Document_ID" < 16514113 AND Document_Name != "A history of Arts" AND Document_Description = "n" OR Other_Details <> "None" AND "Template_ID" != 22 UNION ALL SELECT Other_Details, Document_ID FROM Paragraphs WHERE "Paragraph_ID" < 243399026 AND "Document_ID" > 50123 OR Other_Details = "None"


Question: What driver IDs are used by both drivers with IDs 7 or greater and school bus drivers with IDs greater than 3?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 7 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 3


Question: What Driver IDs are either 10 or less, or 3 or more?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 10 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 3


Question: What Driver ID, other than 10, is also Driver ID 9 for school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 10 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 9


Question: What driver IDs are not equal to 3 in the drivers list, or are less than or equal to 10 in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 3 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: Which driver IDs are 12 or greater and are not school bus drivers, except for driver ID 3?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 12 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


Question: What are the Driver IDs that are not 1 from the driver list, or are greater than 9 from the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 1 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 9


Question: Could you list the aircraft IDs and their average name for aircraft that are either a 'British Aerospace Jetstream 41' with a distance other than 1504 and an ID of 4 or less, or have a distance greater than 4010?

SELECT aid, AVG(name) FROM aircraft WHERE name = "British Aerospace Jetstream 41" AND "distance" != 1504 AND "aid" <= 4 UNION SELECT aid, AVG(name) FROM aircraft WHERE "distance" > 4010


Question: What Aircraft IDs are both not equal to 1 and less than 3, and are found in both the aircraft and airport aircraft lists?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 1 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 3


Question: What are the aircraft IDs that are 4 or greater from the aircraft table, or 2 or less from the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 4 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 2


Question: What are the employee IDs of individuals who have a certificate ID of 556784565 or higher, or are employees with a salary over 48250 or named Betty Adams?

SELECT eid FROM certificate WHERE "eid" >= 556784565 UNION SELECT eid FROM employee WHERE "salary" > 48250 OR name = "Betty Adams"


Question: What driver IDs are 3 or greater in the driver table, but not also 9 or greater in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 3 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


Question: Is aircraft ID 4 in the aircraft table but not in the airport_aircraft table, if we disregard aircraft ID 5 in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 4 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 5


Question: What aircraft IDs are in the aircraft table, other than ID 4, and are not among the aircraft IDs less than 3 that are in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 4 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 3


Question: What is the maximum area size, number of product categories, and number of stores for stores that are either village stores with a ranking better than 3, or have a number of product categories not equal to 1678, or have an area size less than 26.69?

SELECT MAX(Area_size), Number_of_product_category, COUNT(Type) FROM store WHERE "Ranking" > 3 AND Type = "Village Store" OR "Number_of_product_category" <> 1678.0 UNION SELECT MAX(Area_size), Number_of_product_category, COUNT(Type) FROM store WHERE "Area_size" < 26.69


Question: What are the maximum draft number, minimum document ID, and count of draft details for document drafts that are not 'r', except for those that are also not 'k' and are either draft number 14 or document ID 4 or greater?

SELECT MAX(draft_number), MIN(document_id), COUNT(draft_details) FROM Document_Drafts WHERE draft_details <> "r" EXCEPT SELECT MAX(draft_number), MIN(document_id), COUNT(draft_details) FROM Document_Drafts WHERE draft_details != "k" AND "draft_number" = 14 OR "document_id" >= 4


Question: What is the total enrollment of students in schools where the budget invested percentage is 122.5 and the total budgeted percentage is greater than 2.0?

SELECT SUM(T1.Enrollment), T2.Budget_invested_percent FROM School as T1 JOIN budget as T2 ON T1.School_id = T2.School_id WHERE Budget_invested_percent = "122.5" AND "total_budget_percent_budgeted" > 2.0


Question: What are the driver IDs that are not 2 from the driver table, or are 4 or greater from the school_bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 2 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 4


Question: What driver IDs are either exactly 10 from the driver list, or less than or equal to 3 from the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 10 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 3


Question: What are the food allergies?

SELECT Allergy FROM Allergy_Type WHERE AllergyType = "food" INTERSECT SELECT Allergy FROM Allergy_Type WHERE AllergyType <> "food" OR Allergy <> "Ragweed"


Question: What are the driver IDs of drivers who are not driver ID 1, and are not also school bus drivers with IDs 1, 2, or 3?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 1 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 3


Question: What is the smallest 'overdue' document status code that is not described as 'currently working on', and also the smallest document status code that is not 'working'?

SELECT MIN(document_status_code) FROM Ref_Document_Status WHERE document_status_description <> "currently working on" AND document_status_code = "overdue" UNION ALL SELECT MIN(document_status_code) FROM Ref_Document_Status WHERE document_status_code != "working"


Question: What are the maximum ID and the total sum of names when we look at airports and operating companies based on certain conditions?

SELECT MAX(id), SUM(name) FROM airport WHERE IATA = "BRU" OR ICAO != "KBOS" AND City <> "Barcelona" OR name = "Schiphol Airport" AND "id" >= 2 UNION SELECT MAX(id), SUM(name) FROM operate_company WHERE Principal_activities != "Cargo airline" OR "id" >= 7 OR "Group_Equity_Shareholding" != 45.0 OR name != "Hong Kong Airport Services"


Question: What driver IDs are 11 or less and are not also driver IDs of 9 or more associated with school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 11 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


Question: What is the highest vehicle ID for vehicles that are not cars and have an ID greater than 1? Also, what is the highest vehicle ID for vehicles that are either vans or have an ID of 1 or more?

SELECT MAX(vehicle_id) FROM Vehicles WHERE "vehicle_id" > 1 AND vehicle_details != "Car" UNION ALL SELECT MAX(vehicle_id) FROM Vehicles WHERE vehicle_details = "Van" OR "vehicle_id" >= 1


Question: Can you give me the driver IDs that are not 10 from the driver table, along with the driver IDs less than 7 from the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 10 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 7


Question: Which driver IDs are for drivers other than 8, that are not also school bus drivers with IDs up to 10?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: Which driver IDs are on the driver list, excluding driver 8, but not on the school bus driver list, excluding driver 7?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 7


Question: What are the join date, leave date, middle name, date of birth, and staff address ID for staff who either have a staff address ID other than 3, or meet at least one of these conditions: their leave date is not 2018-03-23 22:53:12, their birth date is not 2005-05-02 06:23:36 and staff ID is 7 or less, last name is not Macejkovic, or first name is Margie and middle name is not Mayra?

SELECT date_joined_staff, date_left_staff, middle_name, date_of_birth, staff_address_id FROM Staff WHERE "staff_address_id" <> 3 UNION ALL SELECT date_joined_staff, date_left_staff, middle_name, date_of_birth, staff_address_id FROM Staff WHERE date_left_staff != "2018-03-23 22:53:12" OR date_of_birth <> "2005-05-02 06:23:36" AND "staff_id" <= 7 OR last_name != "Macejkovic" OR middle_name != "Mayra" AND first_name = "Margie"


Question: For each age, what is the age itself, the number of drivers of that age, and the smallest driver ID?  Show me this information for ages that have more than one driver, and also for ages where the smallest driver ID is at least 1 and there are no drivers. Combine these two sets of results.

SELECT Age, COUNT(Name), MIN(Driver_ID) FROM driver GROUP BY Age HAVING COUNT(Name) > 1 UNION SELECT Age, COUNT(Name), MIN(Driver_ID) FROM driver GROUP BY Age HAVING MIN(Driver_ID) >= 1 AND COUNT(Name) < 1


Question: What are the unique Aircraft IDs that are at least 1 from the aircraft list, or at most 1 from the airport aircraft list?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 1 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 1


Question: What are the driver IDs, excluding driver ID 12 and driver ID 10 from school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 12 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: Give me all the driver IDs that are not 5 from the drivers table, along with all the driver IDs that are 3 or greater from the school buses table.

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 5 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 3


Question: What allergies are not animal allergies and are not dog allergies or allergies that are not food?

SELECT Allergy FROM Allergy_Type WHERE AllergyType <> "animal" NOT IN (SELECT Allergy FROM Allergy_Type WHERE Allergy = "Dog" OR AllergyType != "food")


Question: What are the Branch IDs for branches not in London with a membership amount of 112 that opened in 2001, or are not branch ID 7 and not on Valleys Place road, as well as Branch IDs from purchases at branch 3 in 2018?

SELECT Branch_ID FROM branch WHERE City <> "London" AND membership_amount = "112" AND Open_year = "2001" OR "Branch_ID" != 7 AND Address_road != "Valleys Place" UNION ALL SELECT Branch_ID FROM purchase WHERE Branch_ID = "3" AND Year = "2018"


Question: For each city, what is the average age of employees and the year of their award, considering employees who either received an award in 2015 and are from Sale, or are not named Jason Hobson, and only for cities that include employees who are not named Matt Stevens?

SELECT AVG(T1.Age), T2.Year_awarded FROM employee as T1 JOIN evaluation as T2 ON T1.Employee_ID = T2.Employee_ID WHERE Year_awarded = "2015" AND City = "Sale" OR Name <> "Jason Hobson" GROUP BY City HAVING Name <> "Matt Stevens"


Question: Which driver IDs, other than 6, are drivers but not school bus drivers with IDs of 9 or higher?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 6 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


Question: What are the driver IDs that are exactly 3 from the driver list or greater than 9 from the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 3 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 9


Question: What are the 'a_id's from the reviews that satisfy either of these conditions: being for item 7 with a rating of 6 or having an 'a_id' of 5 or more, OR having an 'a_id' that is not 7, a rank that is not 2, or a 'u_id' greater than 2 with an 'i_id' less than 1 and a rating other than 5?

SELECT a_id FROM review WHERE "i_id" = 7 AND "rating" = 6 OR "a_id" >= 5 UNION SELECT a_id FROM review WHERE "a_id" != 7 OR "rank" != 2 OR "u_id" > 2 AND "i_id" < 1 AND "rating" <> 5


Question: What Aircraft IDs are either less than 4 in the aircraft table or not equal to 3 in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 4 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 3


Question: Which Store IDs are either not 4 or belong to a district other than 15, or are Store ID 3 with a product ID less than 1?

SELECT Store_ID FROM store_district WHERE "Store_ID" <> 4 OR "District_ID" != 15 UNION SELECT Store_ID FROM store_product WHERE "Store_ID" = 3 AND "Product_ID" < 1


Question: Which driver IDs, 9 or less, are drivers but not school bus drivers with IDs greater than 3?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 9 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 3


Question: What are the driver IDs that are 5 or greater, but not greater than 9 if they are also listed for school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 9


Question: What are the Pet IDs for pets that are either not ID 2001, or weigh more than 12 pounds, or are at least 3 years old and have an ID less than 2003?

SELECT PetID FROM Pets WHERE "PetID" != 2001 UNION ALL SELECT PetID FROM Pets WHERE "weight" > 12.0 OR "pet_age" >= 3 AND "PetID" < 2003


Question: What aircraft IDs are either specifically ID 2 from the aircraft table, or any ID other than 3 from the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 3


Question: What are the Model IDs, along with their average Maker and model count, for models where the Model ID is greater than 4, as well as for models where the Maker is 10 or greater?

SELECT ModelId, AVG(Maker), COUNT(Model) FROM model_list WHERE "ModelId" > 4 UNION SELECT ModelId, AVG(Maker), COUNT(Model) FROM model_list WHERE "Maker" >= 10


Question: What are the names of companies that are not in the Oil and gas industry and are not named Citigroup, together with the names of people who are not Jerry Corcoran, or are from the United States and have a People ID greater than 2?

SELECT Name FROM company WHERE Industry != "Oil and gas" AND Name != "Citigroup" UNION SELECT Name FROM people WHERE Name != "Jerry Corcoran" OR Nationality = "United States" AND "People_ID" > 2


Question: What aircraft IDs are less than 2 in the aircraft table or not equal to 3 in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 3


Question: What are the earliest years for budgets that meet either of these conditions: (a) the total budget invested percentage is less than 2.2%, the total budget budgeted percentage is less than 2.0%, the year is not 2001, and the budget invested percentage is 146.9%, or (b) the year is 2003 and the invested amount is not 2134?

SELECT MIN(Year) FROM budget WHERE "total_budget_percent_invested" < 2.2 AND "total_budget_percent_budgeted" < 2.0 AND "Year" <> 2001 AND Budget_invested_percent = "146.9" UNION SELECT MIN(Year) FROM budget WHERE "Year" = 2003 AND "Invested" <> 2134


Question: Which driver IDs are greater than 2 but are not also school bus driver IDs, disregarding school bus driver ID 3?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 2 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


Question: What driver IDs are less than 12 in the driver table, or greater than 7 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 12 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 7


Question: What aircraft IDs are either 5 from the aircraft table, or any ID of 1 or more from the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 5 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 1


Question: What driver IDs are used by both drivers with IDs of 10 or greater and school bus drivers with IDs greater than 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 10 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 9


Question: What are the Shop IDs from hiring records for employees with ID 6 or greater, or for part-time shops with Shop ID greater than 8, combined with Shop IDs from shop records for shops named 'HJK' and Shop ID 6?

SELECT Shop_ID FROM hiring WHERE "Employee_ID" >= 6 OR Is_full_time = "F" AND "Shop_ID" > 8 UNION SELECT Shop_ID FROM shop WHERE Name = "HJK" AND "Shop_ID" = 6


Question: Which aircraft IDs, other than 4, are in the aircraft table but not among aircraft IDs greater than 5 in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 4 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 5


Question: Which driver IDs are on both the driver list (excluding ID 1) and the school bus list (excluding ID 7)?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 1 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 7


Question: What Aircraft IDs are in both the aircraft and airport_aircraft tables, where aircraft IDs are not 4 and airport aircraft IDs are 2 or greater?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 4 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2


Question: What are the Aircraft IDs that are greater than 1 in the aircraft table, excluding those that are less than or equal to 3 in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 1 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 3


Question: List driver ID 12 from the driver table and all driver IDs 4 or less from the school bus table.

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 12 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 4


Question: What driver IDs are both greater than 8 and not 9, and are associated with both drivers and school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 8 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 9


Question: What driver IDs are used by both drivers and school buses, excluding driver ID 6 for drivers and driver ID 7 for school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 6 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 7


Question: What Aircraft IDs are greater than 2 in the aircraft table or greater than or equal to 1 in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 1


Question: Can you give me the total staff ID, join dates, earliest last name, number of birth dates, average first name, and staff address ID for staff who were working after '2018-02-26 17:56:31' and whose middle name is not 'Benny', but not for staff who were born on '1996-03-09 08:19:49', or have a staff address ID less than 3 and a staff ID of 4 or more, or are named 'Mertz'?

SELECT SUM(staff_id), date_joined_staff, MIN(last_name), COUNT(date_of_birth), AVG(first_name), staff_address_id FROM Staff WHERE date_left_staff <> "2018-02-26 17:56:31" AND middle_name <> "Benny" EXCEPT SELECT SUM(staff_id), date_joined_staff, MIN(last_name), COUNT(date_of_birth), AVG(first_name), staff_address_id FROM Staff WHERE date_of_birth = "1996-03-09 08:19:49" OR "staff_address_id" < 3 AND "staff_id" >= 4 OR last_name = "Mertz"


Question: Which driver IDs, besides driver ID 2, are drivers but not school bus drivers, besides driver ID 7?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 2 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 7


Question: What driver IDs are less than 6 or greater than 4?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 6 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 4


Question: What aircraft IDs, other than 1, are in the aircraft table but not in the airport_aircraft table if their ID is 2 or greater?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 1 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2


Question: What aircraft IDs are in the aircraft table, except for ID 2, that are not also in the airport aircraft table if we only consider IDs up to 3 in that table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 2 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 3


Question: What are the lesson status, staff ID, and price for lessons where either the staff ID is not 11, or the vehicle ID is greater than 2 and the lesson ID is 7 or more, or the lesson date is not '2018-03-12 00:41:59', or the lesson status is not 'Cancelled', or the price is less than 352, or where either the customer ID is not 5, or the staff ID is not 14 and the price is 231 or more, the lesson time is '9', and the lesson date is not '2018-03-17 19:02:07'?

SELECT lesson_status_code, staff_id, price FROM Lessons WHERE "staff_id" != 11 OR "vehicle_id" > 2 AND "lesson_id" >= 7 OR lesson_date != "2018-03-12 00:41:59" OR lesson_status_code != "Cancelled" OR "price" < 352.0 UNION SELECT lesson_status_code, staff_id, price FROM Lessons WHERE "customer_id" != 5 OR "staff_id" != 14 AND "price" >= 231.0 AND lesson_time = "9" AND lesson_date <> "2018-03-17 19:02:07"


Question: Which driver IDs are either 11 or greater in the driver table, or 9 or less in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 11 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 9


Question: Which airport IDs and altitudes are associated with flight numbers that have at least one flight with a velocity over 240 or piloted by Thompson?

SELECT T1.id, T2.Altitude FROM airport as T1 JOIN flight as T2 ON T1.id == T2.id GROUP BY Vehicle_Flight_number HAVING Velocity > 240.0 OR Pilot = "Thompson"


Question: List the aircraft IDs that are not 4 from the aircraft, or are 2 or less from the airport aircraft.

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 4 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 2


Question: Could you list aircraft ID 2 if it's in the aircraft table, and all other aircraft IDs from the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 2


Question: What driver IDs are either 9 or greater, or 3 or less?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 9 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 3


Question: What aircraft IDs are common to both aircraft (with IDs 1 or greater) and airport aircraft (excluding ID 1)?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 1 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 1


Question: What driver IDs are greater than 2 in the driver list or at least 7 in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 2 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 7


Question: What are the full-time statuses for school buses that are not full-time, or are for school ID 1 or less, or have worked for less than 8 years?

SELECT If_full_time FROM school_bus WHERE If_full_time <> "T" UNION ALL SELECT If_full_time FROM school_bus WHERE "School_ID" <= 1 OR If_full_time <> "T" OR "Years_Working" < 8


Question: Could you list all Store IDs for stores that have an area size of 179.84 or a ranking greater than 9, or that carry products with IDs less than 6?

SELECT Store_ID FROM store WHERE "Area_size" = 179.84 OR "Ranking" > 9 UNION ALL SELECT Store_ID FROM store_product WHERE "Product_ID" < 6


Question: What are the minimum School IDs for schools that are not in 4th grade, or are not school ID 7 and not in Jakarta, or are Punahou School, and also for school buses that are not full time or have a driver ID greater than 3?

SELECT MIN(School_ID) FROM school WHERE Grade != "4th grade" OR "School_ID" != 7 AND Location != "Jakarta, Indonesia" OR School = "Punahou School" UNION ALL SELECT MIN(School_ID) FROM school_bus WHERE If_full_time <> "T" OR "Driver_ID" > 3


Question: What Aircraft IDs are 3 or less in the aircraft table, or 2 or less in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 3 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 2


Question: What are the Driver IDs that are 8 or less from the driver records, or less than 10 from the school bus records?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 8 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: What aircraft IDs are number 3 in the aircraft table but not less than 2 in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 3 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 2


Question: Give me the driver IDs that are 3 or less from the driver table, or are not 4 from the school bus table.

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 3 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 4


Question: Could you list the company IDs for companies that are either headquartered in the USA and not valued at 164.3 billion, or in the oil and gas industry, or not company ID 17, or have sales of at least 82.6 billion and are not named JPMorgan Chase, or have assets less than 2039.1 billion, but are not associated with employee ID 2, a year working other than 1, or company ID 11 in employment records?

SELECT Company_ID FROM company WHERE Headquarters = "USA" AND "Market_Value_in_Billion" <> 164.3 OR Industry = "Oil and gas" OR "Company_ID" <> 17.0 OR "Sales_in_Billion" >= 82.6 AND Name != "JPMorgan Chase" OR "Assets_in_Billion" < 2039.1 EXCEPT SELECT Company_ID FROM employment WHERE "People_ID" = 2 OR "Year_working" != 1 OR "Company_ID" = 11


Question: What is the club ID and the student IDs of members in 'Bootup Baltimore'?

SELECT AVG(T1.ClubID), T2.StuID FROM Club as T1 JOIN Member_of_club as T2 ON T1.ClubID = T2.ClubID WHERE ClubName = "Bootup Baltimore"


Question: What aircraft IDs are in both the aircraft and airport aircraft lists, considering only aircraft IDs up to 3 from the aircraft list and aircraft IDs of 1 or greater from the airport aircraft list?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 3 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 1


Question: What driver IDs of 7 or less are not also school bus driver IDs, considering only school bus drivers with IDs other than 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 7 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 9


Question: What driver IDs, 8 or less, are not among the school bus driver IDs that are 10 or greater?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 10


Question: What driver IDs are less than 12 but not less than or equal to 3 in the school bus records?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 12 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 3


Question: What Driver IDs are either less than 6 in the driver table or 10 or greater in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 6 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 10


Question: What driver IDs are both drivers (excluding driver 6) and school bus drivers (excluding driver 10)?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 6 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: Which Driver IDs are 8 or less from the driver table, and also Driver ID 9 from the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <= 8 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 9


Question: What are the template IDs for documents named 'Do not panic' or with ID 76 or less and not described as 'h', together with template IDs for templates that are not type 'PP' or have an effective date other than '1975-07-16 04:52:10'?

SELECT Template_ID FROM Documents WHERE Document_Name = "Do not panic" OR "Document_ID" <= 76 AND Document_Description <> "h" UNION SELECT Template_ID FROM Templates WHERE Template_Type_Code != "PP" OR Date_Effective_To != "1975-07-16 04:52:10"


Question: What are the feature type codes and names, excluding those named 'Securiyt, eg Burglar Alarm.' if they are also of type 'Amenity', but including those that are not of type 'Security' or are named 'Amenity, eg Pool.'?

SELECT feature_type_code, feature_type_name FROM Ref_Feature_Types WHERE feature_type_name <> "Securiyt, eg Burglar Alarm." AND feature_type_code != "Amenity" UNION SELECT feature_type_code, feature_type_name FROM Ref_Feature_Types WHERE feature_type_code != "Security" OR feature_type_name = "Amenity, eg Pool."


Question: What are the aircraft IDs that are at least 1 from the aircraft list, or are not 5 from the airport aircraft list?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 1 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 5


Question: What driver IDs, besides 9, are not driver ID 7 on school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 9 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 7


Question: What are the driver IDs that are both greater than 6 and less than 9, and are used by both drivers and school buses?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 6 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 9


Question: What are the Shop IDs for shops that are either hiring full-time employees with ID 3 or less, or started hiring in 2012, or have a Shop ID less than 9, or are named 'FC KooTeePee' and not in 'Lahti' and don't have 10000 products, or are managed by 'Mika Laurikainen', or are in the 'Finnair Stadium' district?

SELECT Shop_ID FROM hiring WHERE Is_full_time = "T" AND "Employee_ID" <= 3 OR Start_from = "2012" UNION ALL SELECT Shop_ID FROM shop WHERE "Shop_ID" < 9 OR "Number_products" != 10000 AND Name = "FC KooTeePee" AND Location <> "Lahti" OR Manager_name = "Mika Laurikainen" OR District = "Finnair Stadium"


Question: What aircraft IDs are in both the aircraft list (excluding aircraft ID 5) and the airport aircraft list (excluding aircraft ID 1)?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 5 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 1


Question: What driver IDs, other than 7, are drivers, but also not 3 if 3 is a school bus driver?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 7 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 3


Question: Which Aircraft ID is number 3 in the aircraft table and also not number 2 in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 3 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 2


Question: Which Driver IDs are both greater than 5 and less than 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 5 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 9


Question: Can you find the minimum endowment ID from the endowment table for cases where either the donator name is not 'Distrito Nacional' or the endowment ID is 1 or more and the school ID is 6 or less, and also for cases where the endowment ID is greater than 2?

SELECT MIN(endowment_id) FROM endowment WHERE donator_name != "Distrito Nacional" OR "endowment_id" >= 1 AND "School_id" <= 6 UNION ALL SELECT MIN(endowment_id) FROM endowment WHERE "endowment_id" > 2


Question: What Aircraft IDs are in both the aircraft table (for IDs 2 or greater) and the airport_aircraft table (excluding ID 3)?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 3


Question: Which driver IDs are less than 3 in the driver table but not driver ID 4 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 3 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 4


Question: Which driver IDs are both for drivers with IDs of 7 or greater and for school bus drivers with IDs of 9 or greater?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 7 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


Question: What are the total sales and a year of working for companies, categorized by their asset value, but only for companies and asset value categories that meet certain specific conditions related to company location, financial performance, and size?

SELECT SUM(T1.Sales_in_Billion), T2.Year_working FROM company as T1 JOIN employment as T2 ON T1.Company_ID = T2.Company_ID WHERE Headquarters <> "USA" OR "Sales_in_Billion" <= 447.0 AND "People_ID" > 7 OR "Profits_in_Billion" <> 25.7 AND "Year_working" > 1 OR "Market_Value_in_Billion" > 237.4 OR Name = "ExxonMobil" OR "Assets_in_Billion" <= 1873.9 GROUP BY Assets_in_Billion HAVING Assets_in_Billion <= 2039.1 OR Headquarters = "USA" OR Profits_in_Billion > 11.1 OR Year_working < 1 OR Name = "Wells Fargo" AND Industry = "Banking" OR Market_Value_in_Billion = 107.5 AND Sales_in_Billion <= 143.7


Question: Which driver IDs are drivers (excluding driver ID 9) but not school bus drivers (excluding driver ID 10)?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 9 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: What aircraft IDs are greater than 3 but are not listed in the airport aircraft table, except for aircraft ID 5?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 3 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 5


Question: What driver IDs are there that are 2 or more in the driver table, or less than 10 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 2 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: What driver IDs are 4 or greater from the driver records, or driver ID 4 from the school bus records?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 4 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 4


Question: For each target user, what are the minimum source user ID and the average trust value for entries where either the trust is not 4, or the source user is not 1 and the target user is greater than 2, or the trust is greater than 3?

SELECT MIN(source_u_id), target_u_id, AVG(trust) FROM trust WHERE "trust" != 4 UNION SELECT MIN(source_u_id), target_u_id, AVG(trust) FROM trust WHERE "source_u_id" <> 1 AND "target_u_id" > 2 OR "trust" > 3


Question: What are the Driver IDs that are less than 2 or exactly 10, considering driver and school bus information?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 2 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 10


Question: Which driver IDs are below 8, and are not also driver IDs for school buses with IDs 10 or above?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 10


Question: For document types other than 'Hard Drive', what is the count of document types and the sum of their codes, and can you repeat those values?

SELECT COUNT(document_type_description), SUM(document_type_code) FROM Ref_Document_Types WHERE document_type_code <> "Hard Drive" UNION ALL SELECT COUNT(document_type_description), SUM(document_type_code) FROM Ref_Document_Types WHERE document_type_code <> "Hard Drive"


Question: What are the IDs of flights that are either not on September 3, 1963 and piloted by Thompson, or have a velocity other than 240, are from company 4, use airport ID 6 or less, and are not flight number M2-F1 #39, or have an altitude other than 3650, together with all operate company IDs that are not 2?

SELECT id FROM flight WHERE Date <> "September 3, 1963" AND Pilot = "Thompson" OR "Velocity" != 240.0 AND "company_id" = 4 AND "airport_id" <= 6 AND Vehicle_Flight_number <> "M2-F1 #39" OR "Altitude" <> 3650.0 UNION ALL SELECT id FROM operate_company WHERE "id" <> 2


Question: What driver IDs are in both the driver and school bus records, and are at least 7, but not 9?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 7 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 9


Question: What driver IDs are 10 or greater in the driver table, but are not also driver IDs greater than 7 in the school bus table?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 10 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 7


Question: What driver IDs are greater than 9 in the driver list but not 10 or less in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 9 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: What are the Driver IDs from the driver table, excluding ID 5, except for those that are also in the school_bus table and are less than 3?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID <> 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 3


Question: What are the IDs and the highest titles for albums with IDs under 131, and also for employees with IDs of 5 or more, excluding those born on December 8, 1958?

SELECT id, MAX(title) FROM albums WHERE "id" < 131 UNION ALL SELECT id, MAX(title) FROM employees WHERE "id" >= 5 AND birth_date != "1958-12-08 00:00:00"


Question: What aircraft IDs are in the aircraft table as ID 2 but not in the airport_aircraft table as IDs less than 2?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID = 2 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 2


Question: What Driver IDs are greater than 5, or not equal to 3?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 5 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


Question: Which driver IDs are 10 or greater and are not among the school bus driver IDs, ignoring driver ID 7 in the school bus driver IDs?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID >= 10 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 7


Question: What are the different Aircraft IDs, other than 2, present in either the aircraft or airport_aircraft records?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 2 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 2


Question: What are the Aircraft IDs, excluding ID 4 from the aircraft and ID 3 from the airport aircraft?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 4 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 3


Question: What are the endowment IDs, donator names, and amounts for endowments that have either an amount not equal to 9.83, or an amount of 9.55 or more and a School ID greater than 3?

SELECT endowment_id, donator_name, amount FROM endowment WHERE "amount" != 9.83 UNION SELECT endowment_id, donator_name, amount FROM endowment WHERE "amount" >= 9.55 AND "School_id" > 3


Question: What are the Book IDs for books with an ID of 7 or more, more than 12 issues, or a title other than 'Sheva's War', or for publications with an ID less than 5?

SELECT Book_ID FROM book WHERE "Book_ID" >= 7 OR "Issues" > 12.0 OR Title != "Sheva's War" UNION SELECT Book_ID FROM publication WHERE "Book_ID" < 5


Question: What Aircraft IDs are less than 4 in the aircraft table, or not equal to 1 in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID < 4 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 1


Question: What is the highest document ID of a draft, considering drafts that are not revisions, or are draft number 14, or are not document ID 12, unless it is also the highest document ID of a mailed document, considering mailed documents with ID less than 7, address ID up to 9, and not mailed on January 27, 2013?

SELECT MAX(document_id) FROM Document_Drafts WHERE draft_details != "r" OR "draft_number" = 14 OR "document_id" <> 12 EXCEPT SELECT MAX(document_id) FROM Documents_Mailed WHERE "document_id" < 7 AND "mailed_to_address_id" <= 9 AND mailing_date != "2013-01-27 03:29:31"


Question: What aircraft IDs, excluding 5, are in the aircraft table, and what aircraft IDs, starting from 2, are in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 5 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2


Question: Which driver IDs greater than 5 are not also driver ID 10 in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 5 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 10


Question: What driver IDs are both drivers, excluding driver 2, and school bus drivers with IDs greater than 7?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID != 2 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 7


Question: What driver IDs are either greater than 10, or are not 3 in the school bus list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID > 10 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


Question: Which driver IDs under 3 are drivers, but not school bus drivers, ignoring driver ID 3 in the school bus driver list?

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID < 3 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3