Question: What is the maximum first name, average last name, and average date of birth for customers who meet any of the following conditions: their phone number isn't (297)122-0086, their customer start date isn't 2016-04-08, their last name isn't Leuschke, their customer ID is 2 or greater and their outstanding amount is 1000 or less, their cell phone number isn't 577-584-4864, their first name is Millie, or their customer status is "Bad Customer" and their email is ehowell@example.com? Also, what is the maximum first name, average last name, and average date of birth for staff who meet any of the following conditions: their departure date isn't 2018-02-28, their middle name is Dejon, their last name is Jast and their staff ID isn't 13, their staff address ID isn't 1 and their join date is 2017-08-30, their first name isn't Janessa and their nickname is weissnat.vincenzo, or their birth date isn't 2007-06-11?

SELECT MAX(first_name), AVG(last_name), AVG(date_of_birth) FROM Customers WHERE phone_number <> "(297)122-0086" AND date_became_customer != "2016-04-08 00:28:15" OR last_name != "Leuschke" OR "customer_id" >= 2 AND "amount_outstanding" <= 1000.0 OR cell_mobile_phone_number <> "577-584-4864" OR first_name = "Millie" OR customer_status_code = "Bad Customer" AND email_address = "ehowell@example.com" UNION SELECT MAX(first_name), AVG(last_name), AVG(date_of_birth) FROM Staff WHERE date_left_staff != "2018-02-28 08:26:10" AND middle_name = "Dejon" OR last_name = "Jast" AND "staff_id" <> 13 OR "staff_address_id" <> 1 AND date_joined_staff = "2017-08-30 15:08:37" OR first_name != "Janessa" AND nickname = "weissnat.vincenzo" OR date_of_birth <> "2007-06-11 20:03:28"


Question: What are the IDs of drivers, excluding driver 12, and the IDs of school buses, excluding bus 3?

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 roles, excluding those of managers, held by employees who are not employee ID 5, or have the role "PT", or are not named "Clemens", or have other details that are not "u"?

SELECT role_code FROM Employees WHERE "employee_id" <> 5 OR role_code = "PT" OR employee_name != "Clemens" OR other_details != "u" INTERSECT SELECT role_code FROM Roles WHERE role_description <> "Manager"


Question: What are the states, excluding Connecticut, from the area code state table, and also the states from the votes table where the state is New York or the contestant number is less than 3, the vote ID is less than or equal to 5, and the phone number is less than 6209222712?

SELECT state FROM AREA_CODE_STATE WHERE state != "CT" OR "area_code" <= 217 UNION ALL SELECT state FROM VOTES WHERE state = "NY" OR "contestant_number" < 3 AND "vote_id" <= 5 AND "phone_number" < 6209222712


Question: Which driver IDs are not equal to 9 and are in the driver table but not in the school bus table, where the school bus table driver IDs are greater than or equal to 9?

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 >= 9


Question: What are the aircraft IDs, excluding aircraft ID 1, that are present in both the aircraft and airport_aircraft tables, with aircraft IDs greater than or equal to 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: Which staff IDs are associated with lessons where the staff ID is 12 or less, the vehicle ID isn't 1, the price is over 306.0, or the lesson time isn't "5"? Also, which staff IDs are from the staff table where the staff ID is 12, or the date joined isn't "2016-06-05 22:22:23", or the nickname is "lsenger", or the date of birth isn't "2003-01-16 06:29:11" and the date left is "2018-03-08 04:23:14", or the middle name is "Maiya", or the last name isn't "Turner" and the staff address ID is greater than 13?

SELECT staff_id FROM Lessons WHERE "staff_id" <= 12 OR "vehicle_id" <> 1 OR "price" > 306.0 OR lesson_time != "5" UNION ALL SELECT staff_id FROM Staff WHERE "staff_id" = 12 OR date_joined_staff <> "2016-06-05 22:22:23" OR nickname = "lsenger" OR date_of_birth <> "2003-01-16 06:29:11" AND date_left_staff = "2018-03-08 04:23:14" OR middle_name = "Maiya" OR last_name <> "Turner" AND "staff_address_id" > 13


Question: What are the aircraft IDs that appear in either the aircraft table or the airport_aircraft table, and have an ID greater than or equal to 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 are the aircraft IDs that are less than 2 in the aircraft table, but not equal to 1 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 <> 1


Question: What are the document IDs that are either document ID 20 or have a copy number less than 5, an employee ID not equal to 8, and a draft number greater than 17, or are document ID 12 with other details not equal to "m", a shipping agent code not equal to "FE", and a document type code not equal to "Hard Drive", or a document status code not equal to "working"?

SELECT document_id FROM Circulation_History WHERE "document_id" = 20 OR "copy_number" < 5 AND "employee_id" != 8 AND "draft_number" > 17 UNION SELECT document_id FROM Documents WHERE "document_id" = 12 AND other_details <> "m" AND shipping_agent_code != "FE" AND document_type_code <> "Hard Drive" OR document_status_code != "working"


Question: What are the aircraft IDs that are less than 5 in the aircraft table, combined with the aircraft IDs that are greater than 1 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 > 1


Question: What are the customer IDs of customers who have address ID 1 and are not customer ID 1, or whose status is not "Bad Customer" and email is "nichole59@example.com", or whose cell phone number is "200.830.8723", or whose first name is not "Sigrid", combined with the customer IDs from lessons that are not at time "6" and not on "2018-03-03 15:10:16", or whose status is not "Completed", or whose price is not 199.0?

SELECT customer_id FROM Customers WHERE "customer_address_id" = 1 AND "customer_id" != 1 OR customer_status_code != "Bad Customer" AND email_address = "nichole59@example.com" OR cell_mobile_phone_number = "200.830.8723" OR first_name != "Sigrid" UNION SELECT customer_id FROM Lessons WHERE lesson_time != "6" AND lesson_date <> "2018-03-03 15:10:16" OR lesson_status_code != "Completed" OR "price" != 199.0


Question: What are the phone numbers and vote IDs from the VOTES table, excluding those with phone number 7148407040 and vote ID 1, combined with the phone numbers and vote IDs where the vote ID is 5 or greater, or the phone number is less than 5112677315, the state is not NJ, the creation date is not March 9, 2018 at 7:03:36 PM, and the contestant number is 2?

SELECT phone_number, vote_id FROM VOTES WHERE "phone_number" != 7148407040 AND "vote_id" != 1 UNION SELECT phone_number, vote_id FROM VOTES WHERE "vote_id" >= 5 OR "phone_number" < 5112677315 AND state != "NJ " AND created <> "2018-03-09 19:03:36" AND "contestant_number" = 2


Question: What are the aircraft IDs, excluding ID 5, from the aircraft table, combined with aircraft IDs less than 2 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 < 2


Question: Which driver IDs are greater than or equal to 1 but not found in the school bus table with IDs less than or equal to 10?

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 <= 10


Question: What are the aircraft IDs that are either less than or equal to 2, or equal to 3?

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: Which driver IDs are greater than 6 but not present in the school bus table with driver IDs greater than 3?

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: Which driver IDs are not 9, and which driver IDs are 10, considering both drivers and 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 = 10


Question: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 6 from the driver table and driver ID 9 from the school bus table?

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 is the smallest aircraft ID that is less than or equal to 13, but not the smallest ID of an aircraft with a distance of at least 1504, a name of "Airbus A319", or an ID greater than 11?

SELECT MIN(aid) FROM aircraft WHERE "aid" <= 13 NOT IN (SELECT MIN(aid) FROM aircraft WHERE "distance" >= 1504 OR name = "Airbus A319" OR "aid" > 11)


Question: What are the aircraft IDs that are greater than or equal to 4, excluding those aircraft IDs greater than 2 that are also 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 > 2


Question: Which club IDs meet at least one of the following conditions: the club ID is less than or equal to 3, the start year is not 2000, or the region is France; or, the club ID is less than or equal to 5, the rank is less than 1 and the points are not 139, or the small silver count is greater than or equal to 4?

SELECT Club_ID FROM club WHERE "Club_ID" <= 3 OR "Start_year" <> 2000 OR Region = "France" UNION SELECT Club_ID FROM match_result WHERE "Club_ID" <= 5 OR "Rank" < 1 AND "Points" != 139 OR "Small_Silver" >= 4


Question: What are the aircraft IDs that are not equal to 1 and are present in the aircraft table but not in the airport_aircraft table with IDs greater than or equal to 2?

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 are the driver IDs that are either 6 or less than 7, considering both drivers and 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: What are the driver IDs that are less than or equal to 10 in the driver table, but not present in the school bus table with driver IDs less than 10?

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 < 10


Question: What are the rank, user ID, and item ID for reviews where the user ID is at least 2, the item ID is greater than 5, and the rating is 5 or higher, and also for reviews where the user ID is greater than 2 and the rating is less than 5, or the rank is not 3 and the associated ID is not 4, or the item ID is greater than 1?

SELECT rank, u_id, i_id FROM review WHERE "u_id" >= 2 AND "i_id" > 5 AND "rating" >= 5 INTERSECT SELECT rank, u_id, i_id FROM review WHERE "u_id" > 2 AND "rating" < 5 OR "rank" != 3 AND "a_id" <> 4 OR "i_id" > 1


Question: What are the vehicle details for vehicles with IDs less than 2, but not including "Truck"?

SELECT vehicle_details FROM Vehicles WHERE "vehicle_id" < 2 INTERSECT SELECT vehicle_details FROM Vehicles WHERE vehicle_details != "Truck"


Question: Which driver IDs are less than or equal to 6 but not present in the school bus table with driver IDs greater than or equal to 4?

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 >= 4


Question: Which driver IDs are less than 4 but not equal to 4, considering only those present in the driver table but not 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 are the driver IDs that are either less than or equal to 8 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 <= 8 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: Which driver IDs, excluding driver ID 1, are present in both the driver and school bus tables, but with school bus driver IDs limited to those less than or equal to 10?

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 <= 10


Question: What are the aircraft IDs that are equal to 4 but not equal to 1 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 <> 1


Question: What are the driver IDs greater than 11 from the driver table, combined with the driver IDs from the school bus table that are not equal to 10?

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 <> 10


Question: Which driver IDs are equal to 10 but not less 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 are the aircraft IDs that appear in both the aircraft table with an ID of 2 or greater and the airport_aircraft table with an ID greater than 2?

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 > 2


Question: What are the document IDs where the draft number isn't 1 and the employee ID is less than 2, or where the document ID is greater than 2, combined with the document IDs from draft documents that don't have "w" as draft details or have a draft number less than 17?

SELECT document_id FROM Circulation_History WHERE "draft_number" != 1 AND "employee_id" < 2 OR "document_id" > 2 UNION ALL SELECT document_id FROM Document_Drafts WHERE draft_details != "w" OR "draft_number" < 17


Question: What are the counts of rankings and names, the average creation year, the department ID, and the average budget in billions for departments where the department ID is 15, the name isn't "Interior", or the creation year isn't "1889", combined with the same information for departments where the number of employees is greater than 71436, the name isn't "Commerce", or the budget in billions is at least 11.1?

SELECT COUNT(Ranking), COUNT(Name), AVG(Creation), Department_ID, AVG(Budget_in_Billions) FROM department WHERE "Department_ID" = 15 OR Name <> "Interior" OR Creation <> "1889" UNION ALL SELECT COUNT(Ranking), COUNT(Name), AVG(Creation), Department_ID, AVG(Budget_in_Billions) FROM department WHERE "Num_Employees" > 71436.0 AND Name <> "Commerce" OR "Budget_in_Billions" >= 11.1


Question: What are the aircraft IDs that are less than 2, and also the aircraft ID that is 3?

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: Which driver IDs, excluding ID 10, are found in the 'driver' table, and also which driver IDs, excluding ID 3, are found in 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 <> 3


Question: Which driver IDs, excluding ID 10, are associated with either drivers or school buses?

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 <> 10


Question: Which member IDs are associated with card number LCB7 or are not level 4, but are not member IDs less than 4 in the purchase records?

SELECT Member_ID FROM member WHERE Card_Number = "LCB7" OR "Level" != 4 EXCEPT SELECT Member_ID FROM purchase WHERE "Member_ID" < 4


Question: What are the aircraft IDs greater than 2, and also what are the aircraft IDs greater than 5, considering both the aircraft and 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 > 5


Question: What are the driver IDs greater than 9, and also any driver IDs from school buses that are not 7?

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 != 7


Question: Which driver IDs are greater than 7, or which driver IDs are less than or equal to 3, considering both drivers and 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 <= 3


Question: What is the maximum branch ID and the card number for branches that are not in London and are on Oaks Crescent with a branch ID of 2 or higher and a level of 2 or higher, or are in Columbia, South Carolina, opened in a year other than 2013, and have a card number that is not RE95?

SELECT MAX(T1.Branch_ID), T2.Card_Number FROM branch as T1 JOIN member as T2 ON T1.Name = T2.Name WHERE City <> "London" AND Address_road = "Oaks Crescent" AND "Branch_ID" >= 2 AND "Level" >= 2 OR Hometown = "Columbia, South Carolina" AND Open_year <> "2013" AND Card_Number <> "RE95"


Question: What are the aircraft IDs, excluding aircraft ID 4, from the aircraft table, combined with aircraft IDs less than 5 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 < 5


Question: What is the minimum payment method code for direct debit payments made before a certain date and for amounts under 4032.33, excluding the minimum payment method code for payments not equal to 4610.26 and not from customer 3?

SELECT MIN(payment_method_code) FROM Customer_Payments WHERE payment_method_code = "Direct Debit" AND datetime_payment <> "2018-02-27 20:08:53" AND "amount_payment" < 4032.33 EXCEPT SELECT MIN(payment_method_code) FROM Customer_Payments WHERE "amount_payment" <> 4610.26 AND "customer_id" <> 3


Question: What are the driver IDs, excluding driver ID 4, and also the driver IDs less than 10, from the driver and school bus tables?

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 < 10


Question: What are the driver IDs that are less than 3, considering both drivers and school buses?

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: Which driver IDs are equal to 11 but not less than 4, considering driver IDs from the 'driver' table and excluding those from the 'school_bus' table?

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 < 4


Question: Which driver IDs are equal to 2, but not equal to 3 in the school bus table?

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 state/province/county, city, address counts, country, maximum zip/postcode, and building number for addresses that are not in the USA or have an address ID greater than 1, are in Louisiana, and have a zip code other than 75074, excluding those with a zip code other than 08938 or an address ID not equal to 4?

Louisiana
New Bernieceburgh
1
USA
38197
7089 Mueller Forks

SELECT state_province_county, city, COUNT(address_id), country, MAX(zip_postcode), line_1_number_building FROM Addresses WHERE country <> "USA" OR "address_id" > 1 AND state_province_county = "Louisiana" AND zip_postcode != "75074" EXCEPT SELECT state_province_county, city, COUNT(address_id), country, MAX(zip_postcode), line_1_number_building FROM Addresses WHERE zip_postcode != "08938" OR "address_id" != 4


Question: What is the average District ID for districts with a city area less than 12.0 and a city population greater than 328512.0, excluding District ID 12 and districts headquartered in Jhang City, combined with the average District ID for store districts where the store ID is not 1 and the District ID is 15?

SELECT AVG(District_ID) FROM district WHERE "City_Area" < 12.0 AND "City_Population" > 328512.0 AND "District_ID" != 12 AND Headquartered_City != "Jhang City" UNION ALL SELECT AVG(District_ID) FROM store_district WHERE "Store_ID" <> 1 AND "District_ID" = 15


Question: What are the aircraft IDs that appear in the aircraft table with an ID greater than 1, but not in the airport_aircraft table with an ID of 5 or more?

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 >= 5


Question: Which driver IDs are greater than or equal to 8 but not present in the school bus table with driver IDs greater 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: What is the minimum grade and the sum of school IDs for private schools, schools not in 4th grade, schools not named Punahou School, schools with school ID 1, or schools not in Honolulu, Hawaii, combined with the minimum grade and sum of school IDs for schools not in Jakarta, Indonesia?

SELECT MIN(Grade), SUM(School_ID) FROM school WHERE Type = "Private" OR Grade != "4th grade" OR School != "Punahou School" OR "School_ID" = 1 OR Location <> "Honolulu, Hawaii" UNION ALL SELECT MIN(Grade), SUM(School_ID) FROM school WHERE Location <> "Jakarta, Indonesia"


Question: What are the IDs of drivers who are either in the driver table or the school bus table, excluding driver ID 7?

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 != 7


Question: What are the club IDs that are either less than 3 or belong to BK Häcken and started before the year 2000, and also have a coach who is not male?

SELECT Club_ID FROM club WHERE "Club_ID" < 3 OR Club_name = "BK Häcken" AND "Start_year" < 2000 INTERSECT SELECT Club_ID FROM coach WHERE Gender != "M"


Question: Which district IDs have a city population that is not 89380, but are not associated with any store with an ID of 5 or higher?

SELECT District_ID FROM district WHERE "City_Population" != 89380.0 EXCEPT SELECT District_ID FROM store_district WHERE "Store_ID" >= 5


Question: Which employee IDs are not from Bath or not named Jason Hobson (excluding employee ID 3), or were awarded in a year other than 2015?

SELECT Employee_ID FROM employee WHERE City != "Bath" OR Name != "Jason Hobson" AND "Employee_ID" <> 3 UNION SELECT Employee_ID FROM evaluation WHERE Year_awarded <> "2015"


Question: What are the aircraft IDs that are less than 5, and also the aircraft ID that is equal to 5?

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 district and store IDs for districts greater than 11, and also for districts that are not 4?

SELECT District_ID, Store_ID FROM store_district WHERE "District_ID" > 11 INTERSECT SELECT District_ID, Store_ID FROM store_district WHERE "District_ID" <> 4


Question: How many documents have a draft number of 8 or less and a copy number that is not 10, excluding those with a copy number less than 5?

SELECT COUNT(document_id) FROM Draft_Copies WHERE "draft_number" <= 8 AND "copy_number" <> 10 EXCEPT SELECT COUNT(document_id) FROM Draft_Copies WHERE "copy_number" < 5


Question: What are the album IDs of albums by artists with IDs less than 114 that are not Reggae albums?

SELECT id FROM albums WHERE "artist_id" < 114 INTERSECT SELECT id FROM genres WHERE name != "Reggae"


Question: What are the aircraft IDs, excluding aircraft ID 3, that are not present in the airport_aircraft table with aircraft ID 1?

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 = 1


Question: What are the aircraft IDs that are not 4, and also the aircraft IDs less than 5, considering both aircraft and airport aircraft information?

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 < 5


Question: What are the driver IDs that are either 12 or greater, or less than 9?

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 < 9


Question: Which driver IDs are less than 6 but are not present in the school bus table with driver IDs less than 9?

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 IDs of players who have an ID of 10 and more than 8734 votes, or are not male and not named Judy Wasylycia-Leis? Also, what are the IDs of players who started coaching after 2011, or have a player ID greater than 14, or have a coach ID less than or equal to 2?

SELECT Player_ID FROM player WHERE "Player_ID" = 10 AND "Votes" > 8734 OR Gender != "M" AND Player_name != "Judy Wasylycia-Leis" UNION SELECT Player_ID FROM player_coach WHERE "Starting_year" > 2011 OR "Player_ID" > 14 OR "Coach_ID" <= 2


Question: What are the driver IDs that are less than 7 and also appear in the school bus table, excluding driver ID 4?

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 <> 4


Question: Which driver IDs are not 12, and which driver ID is 9, considering both drivers and 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 = 9


Question: What are the district IDs, excluding district 11, that have a store ID of 1 or less, combined with the district IDs that don't have a store ID of 3?

SELECT District_ID FROM store_district WHERE "District_ID" != 11 AND "Store_ID" <= 1 UNION SELECT District_ID FROM store_district WHERE "Store_ID" <> 3


Question: What amenity feature types are available, excluding those with feature ID 2, descriptions other than "Air Conditioning.", and names other than "Pool", combined with all amenity feature types from the feature type reference table?

SELECT feature_type_code FROM Other_Available_Features WHERE "feature_id" != 2 AND feature_type_code = "Amenity" AND feature_description <> "Air Conditioning." AND feature_name <> "Pool" UNION ALL SELECT feature_type_code FROM Ref_Feature_Types WHERE feature_type_code = "Amenity"


Question: What are the aircraft IDs greater than 2, combined with aircraft IDs from airport records that are not equal to 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: Which driver IDs are less than 12 but not equal to 9, considering only driver IDs from the driver table and excluding those from the school bus table?

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 = 9


Question: Which driver IDs are both less than or equal to 5 and present in the school bus table, excluding driver ID 3?

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 are the other details and name of the employee named Haley, excluding those details and names of employees with an ID greater than 5 and a role code of PT?

SELECT other_details, employee_name FROM Employees WHERE employee_name = "Haley" EXCEPT SELECT other_details, employee_name FROM Employees WHERE "employee_id" > 5 AND role_code = "PT"


Question: What are the IDs of drivers, excluding driver ID 4, and also the IDs of school bus drivers with IDs less than 3?

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 driver IDs that are both greater than or equal to 7 in the driver table and greater than 4 in the school bus table?

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 > 4


Question: What are the driver IDs, excluding driver 7, that are present in both the driver and school bus tables, excluding driver 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: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 10 from the driver table and driver ID 3 from 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 != 3


Question: What are the maximum copy and draft numbers for each document, considering drafts numbered 12 or higher, combined with the maximum copy and draft numbers for each document excluding document ID 2?

SELECT MAX(copy_number), document_id, MAX(draft_number) FROM Draft_Copies WHERE "draft_number" >= 12 UNION SELECT MAX(copy_number), document_id, MAX(draft_number) FROM Draft_Copies WHERE "document_id" <> 2


Question: What are the document IDs that meet both of the following conditions? First, they were either checked out by employee 2 with a copy number less than 5 or have a draft number less than 20 and a document ID greater than 2. Second, they have a document status that isn't "done" and other details that aren't "b", or have a shipping agent code of "SH", or a receipt date that isn't "2005-09-30 00:10:02" and a receipt number that isn't "55" and a document ID less than or equal to 25.

SELECT document_id FROM Circulation_History WHERE "employee_id" = 2 AND "copy_number" < 5 OR "draft_number" < 20 AND "document_id" > 2 INTERSECT SELECT document_id FROM Documents WHERE document_status_code <> "done" AND other_details <> "b" OR shipping_agent_code = "SH" OR receipt_date <> "2005-09-30 00:10:02" AND receipt_number <> "55" AND "document_id" <= 25


Question: What are the aircraft IDs less than 4 from the aircraft table, combined with the aircraft IDs less than 3 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 < 3


Question: What are the driver IDs greater than 11 from the driver table, combined with the 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 IDs of books that satisfy either of these conditions: the writer is not Timothy Truman, or the number of issues is less than 5 and the book ID is less than 2 and the title is not "The Black Lamb"; and also satisfy at least one of these conditions: the price is not 2000000.0, or the publication date is not June 2006 and the publication ID is less than or equal to 5, or the publisher is not Pearson?

SELECT Book_ID FROM book WHERE Writer != "Timothy Truman" OR "Issues" < 5.0 AND "Book_ID" < 2 AND Title <> "The Black Lamb" INTERSECT SELECT Book_ID FROM publication WHERE "Price" <> 2000000.0 OR Publication_Date <> "June 2006" AND "Publication_ID" <= 5 OR Publisher != "Pearson"


Question: Which driver IDs are equal to 5, and which driver IDs are greater than 10, considering both drivers and school buses?

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: Which car makers are listed in the car makers table, excluding the one with ID 1, and also which makers are listed in the model list table where the maker ID is 18 or the model is not "cadillac"?

SELECT Maker FROM car_makers WHERE "Id" <> 1 UNION ALL SELECT Maker FROM model_list WHERE "Maker" = 18 OR Model <> "cadillac"


Question: Which driver IDs are less than 10 but not equal to 7, considering only the driver IDs present in the 'driver' table and excluding those 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 are the names and IDs of features that aren't "Burglar Alarm" and don't have an ID of 2, combined with the names and IDs of features that don't have an ID of 4, aren't of type "Amenity", aren't described as "Swimming Pool.", and aren't named "AirCon"?

SELECT feature_name, feature_id FROM Other_Available_Features WHERE feature_description <> "Burglar Alarm" AND "feature_id" <> 2 UNION SELECT feature_name, feature_id FROM Other_Available_Features WHERE "feature_id" != 4 AND feature_type_code != "Amenity" AND feature_description <> "Swimming Pool." AND feature_name <> "AirCon"


Question: Which member IDs meet any of the following criteria: their card number isn't RT91 and their level is greater than 6, or their name is Trevard Lindley, or their hometown is Jacksonville, Florida; or, they have a purchase at branch 2, or their total purchase weight is less than or equal to 232.09 pounds?

SELECT Member_ID FROM member WHERE Card_Number != "RT91" AND "Level" > 6 OR Name = "Trevard Lindley" OR Hometown = "Jacksonville, Florida" UNION ALL SELECT Member_ID FROM purchase WHERE Branch_ID = "2" OR "Total_pounds" <= 232.09


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

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 != 3


Question: What are the average album titles and IDs for albums where the artist ID is not 272 and the album ID is less than 178, combined with the average album titles and IDs for employees in Calgary who are not IT Staff and whose email isn't margaret@chinookcorp.com, or who are not from Canada, or whose postal code isn't T2P 2T3, or whose phone number isn't +1 (403) 263-4423 and whose ID is less than 3, or whose fax isn't +1 (403) 262-3322, or whose last name isn't Callahan and whose address isn't 7727B 41 Ave and whose first name is Michael, or whose reports to is 2, or whose hire date isn't May 3, 2003 and whose state is AB?

SELECT AVG(title), id FROM albums WHERE "artist_id" != 272 AND "id" < 178 UNION SELECT AVG(title), id FROM employees WHERE city = "Calgary" AND title <> "IT Staff" AND email <> "margaret@chinookcorp.com" OR country != "Canada" OR postal_code <> "T2P 2T3" AND phone != "+1 (403) 263-4423" AND "id" < 3 OR fax <> "+1 (403) 262-3322" OR last_name != "Callahan" AND address <> "7727B 41 Ave" AND first_name = "Michael" OR "reports_to" = 2.0 OR hire_date <> "2003-05-03 00:00:00" AND state = "AB"


Question: How many car makers are not "daimler benz" or are from country "4" and are named "General Motors", combined with the number of cars where the number of cylinders is 6 or less, the weight is 1985, the horsepower isn't "75", and the year is before 1982, or the ID is greater than 361?

SELECT COUNT(Id) FROM car_makers WHERE Maker != "daimler benz" OR Country = "4" AND FullName = "General Motors" UNION ALL SELECT COUNT(Id) FROM cars_data WHERE "Cylinders" <= 6 AND "Weight" = 1985 AND Horsepower <> "75" AND "Year" < 1982 OR "Id" > 361


Question: What are the aircraft IDs that are both less than 2 and also less than 5, considering only the aircraft IDs present in the aircraft and airport_aircraft tables?

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 < 5


Question: What are the smallest document IDs from the draft documents where the draft number is greater than 9 or the document ID is less than or equal to 4, excluding the smallest document IDs from the mailed documents where the mailing date is not "2007-01-01 22:32:11" and the address ID is not 3?

SELECT MIN(document_id) FROM Document_Drafts WHERE "draft_number" > 9 OR "document_id" <= 4 EXCEPT SELECT MIN(document_id) FROM Documents_Mailed WHERE mailing_date != "2007-01-01 22:32:11" AND "mailed_to_address_id" <> 3


Question: What are the IDs of drivers, excluding driver ID 4, and the IDs of school bus drivers, excluding driver ID 9?

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 are the aircraft IDs that are less than 4, but not also aircraft IDs that are 2 or less, considering only the aircraft and airport aircraft tables?

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 <= 2


Question: What are the names and market values of companies that either don't have a company ID of 18, are headquartered in China, don't have profits of 15.7 billion, or have a market value of 154.8 billion, or that have a market value less than 178.7 billion, profits of at least 14.2 billion, are not headquartered in the UK, are named "Industrial and Commercial Bank of China", or have a company ID of 16?

SELECT Name, Market_Value_in_Billion FROM company WHERE "Company_ID" != 18.0 OR Headquarters = "China" OR "Profits_in_Billion" <> 15.7 OR "Market_Value_in_Billion" = 154.8 UNION SELECT Name, Market_Value_in_Billion FROM company WHERE "Market_Value_in_Billion" < 178.7 OR "Profits_in_Billion" >= 14.2 OR Headquarters != "UK" OR Name = "Industrial and Commercial Bank of China" OR "Company_ID" = 16.0


Question: What is the average employee ID from the circulation history where the draft number is less than 17, combined with the average employee ID from the employees table where the employee name is not Koby or other details are not h?

SELECT AVG(employee_id) FROM Circulation_History WHERE "draft_number" < 17 UNION ALL SELECT AVG(employee_id) FROM Employees WHERE employee_name <> "Koby" OR other_details <> "h"


Question: What is the total of the department names where the department ID is 1 and the number of employees is not 109832, or the budget is not 11.1, or the creation year is 1849, excluding the total of department names where the budget is 44.6 and the department ID is less than 7?

SELECT SUM(Name) FROM department WHERE "Department_ID" = 1 AND "Num_Employees" <> 109832.0 OR "Budget_in_Billions" <> 11.1 OR Creation = "1849" EXCEPT SELECT SUM(Name) FROM department WHERE "Budget_in_Billions" = 44.6 AND "Department_ID" < 7


Question: What is the average bonus for each year, excluding 2016, and what is the average bonus for 2016, excluding employee 4, based on the evaluation data?

SELECT Year_awarded, AVG(Bonus) FROM evaluation WHERE Year_awarded <> "2016" UNION SELECT Year_awarded, AVG(Bonus) FROM evaluation WHERE Year_awarded = "2016" AND Employee_ID != "4"


Question: What are the aircraft IDs that appear in both the aircraft table with an ID of 2 or greater and the airport_aircraft table with an ID of 3 or less?

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: What are the aircraft IDs that are less than or equal to 3, excluding those aircraft IDs that are not equal to 3 and appear 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 driver IDs, excluding ID 11, from the driver table, combined with the driver IDs, excluding ID 7, 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 != 7


Question: What are the aircraft IDs that are greater than or equal to 1, and also the aircraft ID 3?

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: Which driver IDs are less than 12 but not equal to 9, considering only the driver IDs present in the driver table and excluding those in the school bus table?

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 <> 9


Question: What are the driver IDs, excluding ID 9, from the driver table, combined with the driver IDs, starting from ID 10, 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 >= 10


Question: What are the driver IDs that are greater than or equal to 9, and also the driver IDs from the school bus table that are not equal to 7?

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 <> 7


Question: Which driver IDs are greater than or equal to 4, but not driver IDs less than 3, considering driver IDs from the driver and school_bus tables?

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 < 3


Question: What are the aircraft IDs that are less than 3 in the aircraft table, but not present in the airport_aircraft table with IDs greater than or equal to 3?

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 driver IDs that are either 2 or 7?

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 member IDs of Matt Lentz who don't have the card number SLB51, and also the member IDs of those who made a purchase with a total of 232.09 pounds?

SELECT Member_ID FROM member WHERE Card_Number != "SLB51" AND Name = "Matt Lentz" UNION ALL SELECT Member_ID FROM purchase WHERE "Total_pounds" = 232.09


Question: What are the driver IDs that appear in both the driver and school bus tables, where the driver ID is less than or equal to 8 in the driver table and greater than 3 in the school bus table?

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 > 3


Question: Which driver IDs are either driver ID 3 or any school bus driver ID that is not 10?

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 less than 12 but not equal to 9, considering only the driver IDs present in the driver table, but not in the school bus table?

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 = 9


Question: What are the aircraft IDs that appear in both the aircraft table and the airport_aircraft table, where the aircraft ID is greater than or equal to 2 in the aircraft table and less than or equal to 2 in the airport_aircraft table?

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 <= 2


Question: What are the aircraft IDs that are either less than or equal to 3 in the aircraft table, or less than or equal to 2 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 is the maximum disk loading and the ID, from the aircraft and airport aircraft tables, where the aircraft ID matches?

SELECT T1.Max_disk_Loading, T2.ID FROM aircraft as T1 JOIN airport_aircraft as T2 ON T1.Aircraft_ID = T2.Aircraft_ID


Question: What are the aircraft IDs, excluding ID 1, that are present in both the aircraft and airport_aircraft tables, excluding ID 5?

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 != 5


Question: Which head IDs are both from Florida, have an ID of 8, are younger than 69, or are not named Dudley Hart, and also belong to a department other than department 2?

SELECT head_ID FROM head WHERE born_state = "Florida" AND "head_ID" = 8 OR "age" < 69.0 OR name != "Dudley Hart" INTERSECT SELECT head_ID FROM management WHERE "department_ID" <> 2


Question: What are the driver IDs that are both less than 10 in the driver table and less than or equal to 3 in the school bus table?

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 <= 3


Question: Which club IDs meet either of the following conditions: the club ID is greater than 1, the club description is "Venture capital fund for student business.", or the club name is "Hopkins Student Enterprises"; or, the member's position in the club is not "Teaching Coordinator"?

SELECT ClubID FROM Club WHERE "ClubID" > 1 OR ClubDesc = "Venture capital fund for student business." OR ClubName = "Hopkins Student Enterprises" UNION SELECT ClubID FROM Member_of_club WHERE Position != "Teaching Coordinator"


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

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 user IDs from the reviews where the article ID is 7 or less and the item ID is 1, or the rating is 10 or higher, or the rank is 6 or less, combined with the user IDs from the user accounts where the name is not "Roxi" and the user ID is not 2?

SELECT u_id FROM review WHERE "a_id" <= 7 AND "i_id" = 1 OR "rating" >= 10 OR "rank" <= 6 UNION ALL SELECT u_id FROM useracct WHERE name != "Roxi" AND "u_id" != 2


Question: Which driver IDs are not equal to 4 and are not present in the school bus table with driver IDs less than 9?

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 < 9


Question: What are the driver IDs that are less than 4, either from the driver table or 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 < 4


Question: What are the driver IDs, excluding driver ID 3, and also the driver IDs greater than or equal to 4, considering both drivers and school buses?

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: What are the driver IDs that are less than 2, and what are the driver IDs that are greater than 9?

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: Which aircraft IDs are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 2 from both?

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 are the aircraft IDs that are less than 4 and also appear in the airport aircraft table, excluding aircraft ID 1?

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 are the IDs of drivers, excluding driver 9, and the IDs of school buses, excluding bus 10?

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 <> 10


Question: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 2 from the driver table and driver ID 10 from the school bus table?

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 != 10


Question: For each nationality, excluding Russians and those born on August 8, 1986, or with a height greater than 207.0, or named "Roman Bragin", show the maximum People ID, the count of names, the count of birth dates, and the sum of heights, but only if the count of names is at most 1, or the sum of heights isn't 182.0, or the maximum People ID is greater than 2. Also, for people named "Maksim Botin" who weren't born on January 22, 1987, or whose height is 205.0 and People ID isn't 3, show the same information grouped by nationality, but only if the maximum People ID isn't 7. Combine both sets of results.

SELECT Nationality, MAX(People_ID), COUNT(Name), COUNT(Birth_Date), SUM(Height) FROM people WHERE Nationality != "Russia" OR Birth_Date <> "August 8, 1986" AND Name = "Roman Bragin" OR "Height" > 207.0 GROUP BY Nationality HAVING COUNT(Name) <= 1 OR SUM(Height) != 182.0 AND COUNT(Birth_Date) != 1 OR MAX(People_ID) > 2 UNION SELECT Nationality, MAX(People_ID), COUNT(Name), COUNT(Birth_Date), SUM(Height) FROM people WHERE Name = "Maksim Botin" AND Birth_Date <> "January 22, 1987" OR "Height" = 205.0 AND "People_ID" != 3 GROUP BY Nationality HAVING MAX(People_ID) != 7


Question: What are the draft details for documents that have a document ID other than 4 and a draft number less than 1, and also have draft details that are not "m" and a document ID less than 12?

SELECT draft_details FROM Document_Drafts WHERE "document_id" != 4 AND "draft_number" < 1 INTERSECT SELECT draft_details FROM Document_Drafts WHERE draft_details != "m" AND "document_id" < 12


Question: Which driver IDs are less than 4 but not equal to 4, considering only the driver and school bus information?

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: Can you give me a list of driver IDs, including those from the driver table that are greater than 3, and those from the school bus table that are less than or equal to 7?

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 <= 7


Question: Can you give me the names of employees who either have an ID of 1 and don't live in Wasps, or are older than 29, or are not named Louis Deacon, but only if those names are also of employees named Andrew Sheridan who either live in Wasps or are not 32 years old?

SELECT Name FROM employee WHERE "Employee_ID" = 1 AND City <> "Wasps" OR "Age" > 29 OR Name != "Louis Deacon" INTERSECT SELECT Name FROM employee WHERE Name = "Andrew Sheridan" AND City = "Wasps" OR "Age" != 32


Question: What is the highest document ID in the Document Drafts table, excluding document ID 7 and where the draft number is 10 or less, except for the highest document ID in the Documents table where the receipt date isn't September 27, 1982 at 2:52 PM, the document type code isn't "Hard Drive", the receipt number isn't "114", the shipping agent code isn't "FE", the other details aren't "z", or the document ID is less than 14?

SELECT MAX(document_id) FROM Document_Drafts WHERE "document_id" <> 7 AND "draft_number" <= 10 EXCEPT SELECT MAX(document_id) FROM Documents WHERE receipt_date != "1982-09-27 14:52:15" AND document_type_code != "Hard Drive" OR receipt_number <> "114" AND shipping_agent_code != "FE" OR other_details != "z" OR "document_id" < 14


Question: Can you give me the IDs of flights that either didn't originate from airport 9, or didn't have Thompson as the pilot, or had a velocity of at least 135, or occurred on May 19, 1964 and didn't have company ID 5, or had an altitude greater than 3650, but only if those IDs also belong to operate_companies that are either named Dragonair or were incorporated in Hong Kong and have an ID of 10?

SELECT id FROM flight WHERE "airport_id" <> 9 OR Pilot != "Thompson" OR "Velocity" >= 135.0 OR Date = "May 19, 1964" AND "company_id" <> 5 OR "Altitude" > 3650.0 INTERSECT SELECT id FROM operate_company WHERE name = "Dragonair" OR Incorporated_in = "Hong Kong" AND "id" = 10


Question: Can you give me the IDs of drivers that are both less than or equal to 11 and also less than 4, considering only unique driver IDs from the driver and school_bus tables?

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 < 4


Question: Can you give me a list of driver IDs, excluding driver ID 8 from the driver table and excluding driver ID 7 from the school_bus table, combining the results and removing any duplicates?

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 <> 7


Question: Can you list all the aircraft IDs, combining those from the aircraft table where the ID is not 3 with those from the airport_aircraft table where the ID is not 2?

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: Which driver IDs are both greater than or equal to 8 in the driver table and greater than 4 in the school_bus table?

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 > 4


Question: What is the largest aircraft ID from the aircraft table where the aircraft is not a CH-53E Super Stallion or the total disk area is not 8,495 ft² (789 m²), but only considering aircraft IDs that are also greater than or equal to 3 in the airport aircraft table?

SELECT MAX(Aircraft_ID) FROM aircraft WHERE Aircraft <> "CH-53E Super Stallion" OR Total_disk_area != "8,495 ft² (789 m²)" INTERSECT SELECT MAX(Aircraft_ID) FROM airport_aircraft WHERE "Aircraft_ID" >= 3


Question: Which driver IDs are not equal to 8 and are also not equal to 4?

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 != 4


Question: Can you give me the IDs from the flight table where either the velocity isn't 135 and the ID is less than 1, or the date is March 28, 1966, or the pilot is Peterson, the vehicle flight number is M2-F1 #14, the airport ID is greater than 3, and the altitude is 0; and also give me all the IDs from the operate_company table where the group equity shareholding isn't 100 or the ID is greater than 10 and the type isn't "Joint Venture"?

SELECT id FROM flight WHERE "Velocity" <> 135.0 AND "id" < 1 OR Date = "March 28, 1966" OR Pilot = "Peterson" AND Vehicle_Flight_number = "M2-F1 #14" AND "airport_id" > 3 AND "Altitude" = 0.0 UNION ALL SELECT id FROM operate_company WHERE "Group_Equity_Shareholding" != 100.0 OR "id" > 10 AND Type != "Joint Venture"


Question: Can you give me a list of driver IDs that are less than 4, excluding any driver IDs that are also in the school bus list, except for driver ID 10?

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: Can you give me a list of driver IDs that are both less than or equal to 10 and also not equal to 7, considering only unique driver IDs from 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 <> 7


Question: Can you give me a list of driver IDs, excluding driver ID 11, that are also driver IDs greater than or equal to 3, considering drivers and school buses?

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: Can you list the sales in billions, assets in billions, and industry for companies that either have assets over 340.5 billion and are not headquartered in China and are not in the Banking industry, or are not named Gazprom and have a Company ID of 13, or have sales of 102 billion, combined with companies that have sales over 447 billion, or profits not equal to 21.5 billion, or are in the Banking industry, or are not named Gazprom, or have a Company ID of 10 and are headquartered in the USA and have a market value not equal to 79.5 billion?

SELECT Sales_in_Billion, Assets_in_Billion, Industry FROM company WHERE "Assets_in_Billion" > 340.5 AND Headquarters <> "China" AND Industry <> "Banking" OR Name <> "Gazprom" AND "Company_ID" = 13.0 OR "Sales_in_Billion" = 102.0 UNION SELECT Sales_in_Billion, Assets_in_Billion, Industry FROM company WHERE "Sales_in_Billion" > 447.0 OR "Profits_in_Billion" != 21.5 OR Industry = "Banking" OR Name != "Gazprom" OR "Company_ID" = 10.0 AND Headquarters = "USA" AND "Market_Value_in_Billion" != 79.5


Question: Which driver IDs are greater than 8 and also not equal to 3, considering only the unique driver IDs in both the driver and school_bus tables?

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 != 3


Question: Could you list the driver IDs that are not equal to 1 and also less than or equal to 9, considering only the driver IDs that appear in both the driver and school bus tables?

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: Can you list the other details and document IDs from the documents where the document description is "y" or the template ID is not 4, combined with the other details and document IDs from the paragraphs where the other details are "None" and the document ID is greater than 651512, or where the paragraph ID is less than or equal to 765713812 and the paragraph text is "Fiji"?

SELECT Other_Details, Document_ID FROM Documents WHERE Document_Description = "y" OR "Template_ID" != 4 UNION ALL SELECT Other_Details, Document_ID FROM Paragraphs WHERE Other_Details = "None" AND "Document_ID" > 651512 OR "Paragraph_ID" <= 765713812 AND Paragraph_Text = "Fiji"


Question: Can you give me a list of driver IDs, including those from the driver table that are greater than 10 and those from the school bus table that are greater than or equal to 4?

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: Can you give me a list of driver IDs that are less than 9 and also appear in the list of school bus driver IDs, excluding driver ID 9?

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 <> 9


Question: Which driver IDs, excluding driver ID 8, are also driver ID 3 in the school bus records?

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 = 3


Question: Can you give me a list of driver IDs, excluding driver ID 1, that are not also driver IDs, excluding driver ID 10, found in the school bus table?

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 != 10


Question: Can you give me the IDs of drivers, up to ID 5, excluding the IDs of school bus drivers up to ID 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: Can you give me a list of driver IDs, including those that are equal to 3 from the driver table, and those that are less than 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: Can you give me the zip code, building address, address ID, and state for all addresses where either the building address is not "4834 Schaefer Light Suite 947", or the city is not "South Eugene" and the state is not "Georgia", or the zip code is "27559" and the address ID is not 14, combined with all addresses where the country is not "USA"?

SELECT zip_postcode, line_1_number_building, address_id, state_province_county FROM Addresses WHERE line_1_number_building != "4834 Schaefer Light Suite 947" OR city <> "South Eugene" AND state_province_county != "Georgia" OR zip_postcode = "27559" AND "address_id" != 14 UNION SELECT zip_postcode, line_1_number_building, address_id, state_province_county FROM Addresses WHERE country != "USA"


Question: Can you give me a list of driver IDs, combining those from the driver table that are not 12 with those from the school_bus table that are less than 7, removing any duplicates?

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 is the earliest alphabetically listed party in district 3, and what is the earliest alphabetically listed party that is not Democratic?

SELECT MIN(Party) FROM election WHERE "District" = 3 UNION SELECT MIN(Party) FROM party WHERE Party <> "Democratic"


Question: Can you give me the IDs of drivers, up to ID 3, excluding the IDs of school bus drivers up to ID 7?

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 <= 7


Question: Can you give me a list of People IDs from the people table, including those who graduated from a college in California but aren't from the United States, or whose People ID isn't 4, or whose age isn't 30, combined with those whose People ID isn't 5, didn't graduate from Northeastern, aren't from the United States, and aren't named Tim Naegeli?

SELECT People_ID FROM people WHERE Graduation_College = "California" AND Nationality != "United States" OR "People_ID" <> 4 OR "Age" <> 30 UNION ALL SELECT People_ID FROM people WHERE "People_ID" != 5 AND Graduation_College <> "Northeastern" AND Nationality != "United States" AND Name != "Tim Naegeli"


Question: Which driver IDs, excluding driver 11, are also school bus driver IDs, excluding driver 7?

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 <> 7


Question: Which aircraft IDs, excluding aircraft ID 4, are present in the aircraft table and also have an aircraft ID of 2 or greater in 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 >= 2


Question: Can you list all the aircraft IDs, including those that appear with an ID of 3 in the aircraft table and those that appear with an ID of 1 or greater 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 >= 1


Question: Which driver IDs are both greater than or equal to 3 and present in the driver table, and also less than 9 and present in the school_bus table?

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: Can you give me a list of driver IDs, excluding driver ID 1, that are not also driver ID 4 in the school bus list?

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: Can you give me a list of driver IDs less than 3 from the driver table, excluding any driver IDs that are equal to 10 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 = 10


Question: Which driver IDs, excluding driver ID 7, are not also driver IDs greater than 10 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 > 10


Question: Which driver IDs, excluding driver ID 9, are in the driver table but not in the school bus table if we only consider driver IDs less than or equal to 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: What is the total driver ID for Democratic drivers who are 52 years old, excluding the total driver ID for school bus drivers who are not full-time, have worked for a number of years other than 3, have a driver ID of 10 or less, or have a school ID of 4 or less?

SELECT SUM(Driver_ID) FROM driver WHERE Party = "Dem" AND "Age" = 52 EXCEPT SELECT SUM(Driver_ID) FROM school_bus WHERE If_full_time <> "T" OR "Years_Working" != 3 OR "Driver_ID" <= 10 OR "School_ID" <= 4


Question: Can you give me a list of driver IDs that are less than 3, excluding any driver IDs that are 4 or greater, considering only the driver IDs that appear in the driver table and 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: Can you give me a list of driver IDs, combining those from the driver table excluding ID 8 with those from the school bus table excluding ID 10?

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: Can you give me a list of driver IDs, including those from the driver table where the ID is greater than 12, and those from the school bus table where the ID is 4 or greater?

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: Which driver IDs are greater than 6 and also less than or equal to 7?

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: Can you give me a list of driver IDs, up to 5, that are in the driver table but not in the school bus table, where only driver IDs up to 4 are considered 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 <= 4


Question: Can you tell me the locations and counties of schools that meet either of these sets of criteria: first, schools that aren't in Bremen, don't have Redskins as a mascot, are named New Prairie 1, aren't in IHSAA Football Class AAA, and have a school ID of 3; or schools where the enrollment is 316 and the county isn't 50 Marshall; or schools that aren't in IHSAA Class AAA; and also meet either of these sets of criteria: first, schools that aren't in Bourbon and are in 71 St. Joseph County; or schools where the enrollment is less than 852, aren't in IHSAA Football Class AAA, don't have a school ID of 2, and have Falcons as a mascot?

SELECT Location, County FROM School WHERE Location != "Bremen" AND Mascot != "Redskins" AND School_name = "New Prairie 1" AND IHSAA_Football_Class <> "AAA" AND School_id = "3" OR "Enrollment" = 316 AND County <> "50 Marshall" OR IHSAA_Class <> "AAA" INTERSECT SELECT Location, County FROM School WHERE Location != "Bourbon" AND County = "71 St. Joseph" OR "Enrollment" < 852 AND IHSAA_Football_Class != "AAA" AND School_id != "2" AND Mascot = "Falcons"


Question: Which aircraft have an ID of 2, excluding any aircraft that are associated with airports and have an ID of 1 or less?

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 <= 1


Question: Can you give me a list of driver IDs that are less than 1 from the driver table, combined with a list of driver IDs that are 3 or greater from the school bus table?

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 >= 3


Question: Which driver IDs, excluding driver ID 11, are not also driver IDs, excluding driver ID 3, of 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 != 3


Question: Can you give me a list of driver IDs that are both greater than or equal to 5 and not equal to 4, considering only drivers who appear in both the driver and school bus records?

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 <> 4


Question: Can you give me a list of document IDs from the Documents table where the other details are not "x", the receipt number is not "61", or the shipping agent code is not "FE", combined with a list of document IDs from the Documents_Mailed table where the mailing date is not January 14th, 1982 at 5:50:54 AM, the document ID is not 4, or the mailed to address ID is greater than 7?

SELECT document_id FROM Documents WHERE other_details <> "x" OR receipt_number != "61" OR shipping_agent_code <> "FE" UNION SELECT document_id FROM Documents_Mailed WHERE mailing_date != "1982-01-14 05:50:54" AND "document_id" != 4 OR "mailed_to_address_id" > 7


Question: Which aircraft, excluding aircraft ID 3, are also aircraft with ID 1 found at the airport?

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 is the total of all contestant names excluding Kelly Clauss, combined with the total of all contestant names where the contestant number is 3 or greater, or the contestant name is not Allie Rogalski?

SELECT SUM(contestant_name) FROM CONTESTANTS WHERE contestant_name != "Kelly Clauss" UNION SELECT SUM(contestant_name) FROM CONTESTANTS WHERE "contestant_number" >= 3 OR contestant_name <> "Allie Rogalski"


Question: Which schools that teach 1st to 3rd grade do not have a school bus driver with an ID other than 7 who has worked a number of years other than 3?

SELECT School_ID FROM school WHERE Grade = "1st-3rd grade" EXCEPT SELECT School_ID FROM school_bus WHERE "Driver_ID" <> 7 AND "Years_Working" != 3


Question: What are the aircraft IDs, greater than or equal to 5, that are present in the aircraft table but not in the airport_aircraft table, considering each aircraft ID only once in each table?

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 <= 1


Question: Can you give me the IDs of drivers with IDs less than or equal to 2, excluding those driver IDs that are also less than or equal to 3 in the school bus table?

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: Can you give me the IDs of aircraft that either have a maximum gross weight of 1,370 lb (635 kg), or are not a Mil Mi-26 and also don't have a description of "Tandem rotor helicopter", or don't have a maximum disk loading of 2.6 lb/ft² (14 kg/m²) or a total disk area of 497 ft² (46.2 m²), but only if their Aircraft ID is not 1 in the airport aircraft table?

SELECT Aircraft_ID FROM aircraft WHERE Max_Gross_Weight = "1,370 lb (635 kg)" OR Aircraft <> "Mil Mi-26" AND Description != "Tandem rotor helicopter" OR Max_disk_Loading != "2.6 lb/ft² (14 kg/m²)" OR Total_disk_area != "497 ft² (46.2 m²)" INTERSECT SELECT Aircraft_ID FROM airport_aircraft WHERE "Aircraft_ID" != 1


Question: Can you give me a list of Store IDs for stores that are either named "Neguac" or have a ranking of 2 or higher, excluding "Village Stores", combined with a list of Store IDs from the store district table where the District ID is not 15?

SELECT Store_ID FROM store WHERE Type != "Village Store" AND Store_Name = "Neguac" OR "Ranking" >= 2 UNION SELECT Store_ID FROM store_district WHERE "District_ID" <> 15


Question: Can you give me a list of driver IDs that are both greater than or equal to 7 and also not equal to 7, considering drivers from the driver table and the school_bus table?

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 != 7


Question: Can you give me a list of driver IDs that are 11 or greater from the driver table, excluding any driver IDs greater than 9 that are in the school_bus table?

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: Can you list all driver IDs that are less than 9 from the driver table, and combine that with the driver ID 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: Can you give me a list of driver IDs, including those greater than 8 from the driver list and those equal to 4 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 = 4


Question: What is the average document type code for overdue documents, or documents with a receipt number other than 37, a shipping agent code other than FE, a document type code other than Paper, and other details equal to "r", but only considering the average document type code that is also found in the reference document types where the description is not "f" and the code is not "Hard Drive"?

SELECT AVG(document_type_code) FROM Documents WHERE document_status_code = "overdue" OR receipt_number != "37" AND shipping_agent_code <> "FE" AND document_type_code <> "Paper" AND other_details = "r" INTERSECT SELECT AVG(document_type_code) FROM Ref_Document_Types WHERE document_type_description != "f" AND document_type_code != "Hard Drive"


Question: Can you give me a list of driver IDs that are greater than or equal to 7, excluding any driver IDs less than or equal to 7 that are also in the school bus driver list?

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 <= 7


Question: Can you give me a list of driver IDs, including those from the driver table that are less than 9, and those from the school bus table that are greater than or equal to 3?

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: Can you list the aircraft IDs, first from the aircraft table where the ID is not equal to 1, and then from the airport_aircraft table where the ID is greater than 5, removing any duplicates?

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: Can you give me a list of driver IDs less than 12 that appear in the driver table, excluding those driver IDs less than 4 that are found in the school bus table?

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 < 4


Question: Which driver IDs are both greater than 9 and not equal to 4, considering only the driver IDs that appear in both the driver and school bus records?

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 != 4


Question: Can you give me a list of driver IDs that are less than 2 from the driver table, combined with a list of driver IDs that are less than or equal to 10 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 <= 10


Question: Which driver IDs are both greater than 2 and also greater than or equal to 10 and appear in both the driver and school bus records?

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: Can you list all the copy numbers from the draft copies table where the document ID is less than or equal to 23, or the draft number is 17, and also include any copy numbers that are equal to 5?

SELECT copy_number FROM Draft_Copies WHERE "document_id" <= 23 OR "draft_number" = 17 UNION SELECT copy_number FROM Draft_Copies WHERE "copy_number" = 5


Question: Can you list the aircraft IDs, excluding aircraft ID 5, that are present in the aircraft table but not in the airport_aircraft table where the aircraft ID is less than or equal to 3?

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 <= 3


Question: Can you give me the Club ID, Club name, and Start year for all clubs that are either in the UK, started in 2011 with a Club ID of 2 or greater, or have a name that is not AIK, combined with the Club ID, Club name, and Start year for all clubs not in France?

SELECT Club_ID, Club_name, Start_year FROM club WHERE Region = "UK" OR "Start_year" = 2011 AND "Club_ID" >= 2 OR Club_name <> "AIK" UNION SELECT Club_ID, Club_name, Start_year FROM club WHERE Region <> "France"


Question: Can you give me a list of driver IDs, excluding driver ID 8, that are not also driver IDs in the school bus table, excluding driver ID 3?

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 != 3


Question: Can you list the aircraft IDs, including aircraft ID 1 from the aircraft table and all aircraft IDs except 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 is the difference between the number of available features that are not amenities or have a feature ID less than 3, and the number of property features for properties that are not property ID 12 and do not have the description "quo"?

SELECT COUNT(feature_id) FROM Other_Available_Features WHERE feature_type_code <> "Amenity" OR "feature_id" < 3 EXCEPT SELECT COUNT(feature_id) FROM Other_Property_Features WHERE "property_id" != 12 AND property_feature_description != "quo"


Question: Can you give me a list of driver IDs that are greater than 9, excluding any driver IDs less than 7 that are also 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 < 7


Question: Can you give me a list of aircraft IDs, including those that are equal to 3 from the aircraft table, and those that are less than or equal to 5 from 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 <= 5


Question: Can you give me a list of driver IDs, including those from the driver table that are less than or equal to 12, and those from the school bus table that are greater than 10?

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: Can you show me the Branch ID and Register Year from the membership register branch table, including entries where the Register Year is not 2017 or the Member ID is 8 or greater, combined with entries where the Member ID is greater than 5 or the Branch ID is not 4?

SELECT Branch_ID, Register_Year FROM membership_register_branch WHERE Register_Year <> "2017" OR "Member_ID" >= 8 UNION SELECT Branch_ID, Register_Year FROM membership_register_branch WHERE "Member_ID" > 5 OR Branch_ID <> "4"


Question: Can you list the aircraft IDs that appear more than once in the aircraft table, where the ID is greater than 1, combined with the aircraft IDs that appear more than once in the airport_aircraft table, where the ID is at least 3?

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: Can you give me the city, age, employee ID, and name of employees who are both not from Wasps and are 23 or younger, and also either have an employee ID of 8 or less, or are named Louis Deacon?

SELECT City, Age, Employee_ID, Name FROM employee WHERE City <> "Wasps" AND "Age" <= 23 INTERSECT SELECT City, Age, Employee_ID, Name FROM employee WHERE "Employee_ID" <= 8 OR Name = "Louis Deacon"


Question: Could you list the document IDs from the circulation history where the document ID is at least 1, the employee ID is at least 8, the copy number is not 4, and the draft number is 17, along with the document IDs from the documents mailed table where the mailing date is not April 1st, 1977 at 5:03 PM?

SELECT document_id FROM Circulation_History WHERE "document_id" >= 1 AND "employee_id" >= 8 AND "copy_number" <> 4 AND "draft_number" = 17 UNION ALL SELECT document_id FROM Documents_Mailed WHERE mailing_date != "1977-04-01 17:03:50"


Question: Can you give me a list of driver IDs, excluding driver ID 8, that are not also driver IDs, excluding driver ID 4, 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: Can you give me the contestant number for Nita Coster, along with the contestant numbers of anyone who voted from a state other than California using the phone number 7148407040?

SELECT contestant_number FROM CONTESTANTS WHERE contestant_name = "Nita Coster" UNION ALL SELECT contestant_number FROM VOTES WHERE "phone_number" = 7148407040 AND state <> "CA"


Question: Can you give me a list of aircraft IDs that are less than 3, excluding any aircraft IDs that also appear in the airport aircraft list, except for aircraft ID 1?

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 != 1


Question: What is the smallest document ID from document drafts excluding those with draft number 12, combined with the smallest document ID from documents excluding those with a "working" status, or a receipt date other than "1983-09-26 09:32:56", or a document type other than "Paper" when the receipt number is not "93"?

SELECT MIN(document_id) FROM Document_Drafts WHERE "draft_number" != 12 UNION SELECT MIN(document_id) FROM Documents WHERE document_status_code != "working" OR receipt_date != "1983-09-26 09:32:56" OR document_type_code <> "Paper" AND receipt_number != "93"


Question: Can you give me a list of driver IDs that appear in the driver table, excluding driver ID 1, but also excluding any driver IDs that appear in the school_bus table and are greater than 10?

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 > 10


Question: Can you give me the continent IDs and their corresponding continent names, excluding Australia, but also excluding the continent IDs and names where the continent ID is not 4?

SELECT ContId, MIN(Continent) FROM continents WHERE Continent <> "australia" EXCEPT SELECT ContId, MIN(Continent) FROM continents WHERE "ContId" != 4


Question: Can you list the car makers that are either "ford" and not from country "3" with an ID of 12, or are named "Toyota", and also list the makers from the model list where the model isn't "renault" and the maker is less than or equal to 17, or the model ID is greater than or equal to 23?

SELECT Maker FROM car_makers WHERE Country != "3" AND Maker = "ford" AND "Id" = 12 OR FullName = "Toyota" UNION SELECT Maker FROM model_list WHERE Model != "renault" AND "Maker" <= 17 OR "ModelId" >= 23


Question: Can you give me a list of driver IDs from the driver table, where each ID is greater than 1, excluding any driver IDs that are also in the school_bus table and equal to 9?

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 = 9


Question: Can you give me the first names of students who either don't have advisor 1121, or aren't student ID 1028, or aren't female, or have a major less than 600, but exclude the first names of students who either have an advisor less than or equal to 2311 and aren't male, or are not 27 years old, or are student ID 1010 or higher and named Dinesh?

SELECT Fname FROM Student WHERE "Advisor" <> 1121 OR "StuID" <> 1028 OR Sex != "F" OR "Major" < 600 EXCEPT SELECT Fname FROM Student WHERE "Advisor" <= 2311 AND Sex <> "M" OR "Age" != 27 OR "StuID" >= 1010 AND Fname = "Dinesh"


Question: Can you give me a list of driver IDs, including those from the driver table that are greater than 2, and those from the school bus table that are not equal to 10?

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: Could you give me a list of member IDs that are both not equal to 3 in the membership register branch and also appear in the purchase table where either the total pounds is less than or equal to 232.09 and the member ID is less than or equal to 6, or the year is not 2018?

SELECT Member_ID FROM membership_register_branch WHERE "Member_ID" <> 3 INTERSECT SELECT Member_ID FROM purchase WHERE "Total_pounds" <= 232.09 AND "Member_ID" <= 6 OR Year != "2018"


Question: Could you list the names of employees who are not 30 years old and have an employee ID less than 5, combined with the names of shops that are not in the Arto Tolsa Areena district, or don't have the name HJK, or aren't located in Kuopio, or have 3516 or more products, or have a shop ID less than 7 and are managed by Pekka Lyyski?

SELECT Name FROM employee WHERE "Age" != 30 AND "Employee_ID" < 5 UNION SELECT Name FROM shop WHERE District <> "Arto Tolsa Areena" OR Name != "HJK" OR Location <> "Kuopio" OR "Number_products" >= 3516 OR "Shop_ID" < 7 AND Manager_name = "Pekka Lyyski"


Question: Which driver IDs are equal to 5 in the driver table, but not less than or equal to 3 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 <= 3


Question: Can you give me a list of driver IDs that are less than 12, and also include driver ID 3?

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: Can you give me a list of driver IDs that are 12 or greater, excluding those driver IDs that are greater than 4 and are also in the school bus table?

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 > 4


Question: Can you give me the school ID, average percentage of total budget budgeted, budgeted amount, maximum percentage of budget invested, and invested amount from the budget table, excluding the results where the year is 2006 or the invested amount is greater than 85249 and both the percentage of total budget budgeted and invested are greater than 2.0, but including only those entries where either the percentage of total budget invested is greater than 2.2, or the budgeted amount is not 6803 and the school ID is greater than or equal to 1, or the percentage of total budget budgeted is greater than or equal to 2.4 and the budget invested percentage is not 146.9?

SELECT School_id, AVG(total_budget_percent_budgeted), Budgeted, MAX(Budget_invested_percent), Invested FROM budget WHERE "total_budget_percent_invested" > 2.2 OR "Budgeted" <> 6803 AND "School_id" >= 1 OR "total_budget_percent_budgeted" >= 2.4 AND Budget_invested_percent <> "146.9" EXCEPT SELECT School_id, AVG(total_budget_percent_budgeted), Budgeted, MAX(Budget_invested_percent), Invested FROM budget WHERE "Year" = 2006 OR "Invested" > 85249 AND "total_budget_percent_budgeted" > 2.0 AND "total_budget_percent_invested" > 2.0


Question: Can you give me a list of driver IDs less than or equal to 9, excluding any driver IDs that appear on the school bus list, unless that driver ID is 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: Can you list the aircraft IDs that are greater than 1, and also list the aircraft IDs from the airport aircraft that are less than or equal to 5?

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: Can you give me a list of driver IDs, including those from the driver table excluding driver ID 10, and those from the school bus table with driver IDs of 7 or higher?

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: Can you give me a list of driver IDs, including those from the driver table excluding driver ID 9, and those from the school bus table with driver IDs up to 7?

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 <= 7


Question: Which driver IDs are both less than or equal to 5 in the driver table and less than 7 in the school_bus table?

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 < 7


Question: Can you list the aircraft IDs that are less than or equal to 1 from the aircraft table, and also include the aircraft ID 2 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 = 2


Question: Can you give me a list of driver IDs, including those from the driver table that are greater than 12, and those from the school bus table that are less than or equal to 9?

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 <= 9


Question: Can you give me a list of driver IDs that are less than 5 and also not equal to 4, considering all driver IDs from both the driver and school bus lists?

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 != 4


Question: Can you give me a list of customer IDs who didn't pay with direct debit, combined with a list of customer IDs from lessons taught by staff with an ID less than 8, for lesson ID 6, that didn't cost 199 dollars?

SELECT customer_id FROM Customer_Payments WHERE payment_method_code != "Direct Debit" UNION SELECT customer_id FROM Lessons WHERE "staff_id" < 8 AND "lesson_id" = 6 AND "price" != 199.0


Question: What aircraft IDs, excluding ID 3, are present in the aircraft table and also have an ID of 2 or greater 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: What is the highest property ID from the Other_Property_Features table, excluding entries where the property feature description is "hic" and the property ID is 14, combined with the highest property ID from the Properties table where the first apartment feature is not "aut" and the date on the market is "1993-08-04 10:49:04", or the second house feature is "None", or the first shop feature is not "None" and the third field feature is "None"?

SELECT MAX(property_id) FROM Other_Property_Features WHERE property_feature_description <> "hic" AND "property_id" = 14 UNION ALL SELECT MAX(property_id) FROM Properties WHERE apt_feature_1 <> "aut" AND date_on_market = "1993-08-04 10:49:04" OR hse_feature_2 = "None" OR shp_feature_1 != "None" AND fld_feature_3 = "None"


Question: Can you list all feature type names and codes, excluding those named "Amenity, eg Pool." with the code "Amenity", and also excluding those with the code "Amenity" and named "Securiyt, eg Burglar Alarm."?

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


Question: What are the average role codes and role descriptions for Proof Managers, excluding those with the role code "PT", combined with the average role codes and role descriptions for all other roles?

SELECT AVG(role_code), role_description FROM Roles WHERE role_code != "PT" AND role_description = "Proof Manager" UNION SELECT AVG(role_code), role_description FROM Roles WHERE role_description != "Proof Manager"


Question: Which driver IDs are both greater than 4 and also equal to 10?

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 = 10


Question: Which driver IDs, excluding driver ID 9, are not also driver IDs of school buses where the school bus driver ID is greater than 7?

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: Can you give me a list of all the driver IDs, excluding driver ID 3 from the driver table and excluding driver ID 4 from the school bus table, combining the results into a single 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 <> 4


Question: Can you list the names and codes of all shipping agents, excluding those with the description "k", and also excluding those named "Fedex"?

SELECT shipping_agent_name, shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_description <> "k" UNION SELECT shipping_agent_name, shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name != "Fedex"


Question: Can you give me the average RoomId, the sum of bedType, the maximum occupancy, the count of basePrice, and the number of beds for rooms that are not Queen bed type or have the name "Mendicant with cryptic" and have a base price that's not 100 or a RoomId that's not "HBB" or have 2 beds, but only if these results also include the average RoomId, the sum of bedType, the maximum occupancy, the count of basePrice, and the number of beds for rooms where the RoomId is not "CAS"?

AVG(RoomId) SUM(bedType) maxOccupancy COUNT(basePrice) beds

SELECT AVG(RoomId), SUM(bedType), maxOccupancy, COUNT(basePrice), beds FROM Rooms WHERE bedType <> "Queen" OR roomName = "Mendicant with cryptic" AND "basePrice" <> 100 OR RoomId <> "HBB" OR "beds" = 2 INTERSECT SELECT AVG(RoomId), SUM(bedType), maxOccupancy, COUNT(basePrice), beds FROM Rooms WHERE RoomId <> "CAS"


Question: Can you give me a list of all driver IDs, excluding driver ID 7 from the driver table and excluding driver ID 10 from 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 <> 10