Question: What are the distances for SAAB 340 aircraft with an aid less than or equal to 15, excluding distances from flights to Los Angeles, flights arriving on April 12, 2005 at 09:40, flights not originating from Los Angeles, flights with a price not equal to 220.98, and flights departing on a date other than April 12, 2005 at 08:32 and a distance greater than 802?

SELECT distance FROM aircraft WHERE name = "SAAB 340" AND "aid" <= 15 EXCEPT SELECT distance FROM flight WHERE destination = "Los Angeles" OR arrival_date = "04/12/2005 09:40" OR origin != "Los Angeles" OR "price" != 220.98 OR departure_date <> "04/12/2005 08:32" AND "distance" > 802


Question: What are the driver IDs greater than 3 that are in the driver table but not in the school bus table, where the driver IDs in the school bus table are greater than 4?

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


Question: What are the aircraft IDs that appear in both the aircraft table (with IDs no greater than 4) and the airport_aircraft table (with IDs no greater than 3)?

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


Question: What are the driver IDs that are either 6 or less than 9?

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


Question: What are the IDs of books written by Dave Gibbons that don't have 4 issues, and also published by Springer Nature, or have a book ID other than 5, or a price of 2,000,000?

SELECT Book_ID FROM book WHERE Writer = "Dave Gibbons" AND "Issues" != 4.0 INTERSECT SELECT Book_ID FROM publication WHERE Publisher = "Springer Nature" OR "Book_ID" != 5 OR "Price" = 2000000.0


Question: What are the year awarded, bonus, and employee ID for evaluations not from 2018, and also for evaluations where the bonus is less than 3200 and the employee ID is not 1?

SELECT Year_awarded, Bonus, Employee_ID FROM evaluation WHERE Year_awarded <> "2018" UNION SELECT Year_awarded, Bonus, Employee_ID FROM evaluation WHERE "Bonus" < 3200.0 AND Employee_ID != "1"


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

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


Question: What are the driver IDs greater than 4, and also any driver IDs from school buses that are not equal to 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 greater than 5, and also what are the driver IDs from school buses that are 7 or greater?

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


Question: What are the driver IDs, excluding driver ID 12, and also the driver IDs from school buses that are 9 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 >= 9


Question: What are the driver IDs that are either 11 or greater, or less than 7?

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 is the minimum city area and the store ID for districts where the city population is not 530438, or the store ID is less than or equal to 1, and the city area is not 22, and the district name is not "Chiniot District"?

SELECT MIN(T1.City_Area), T2.Store_ID FROM district as T1 JOIN store_district as T2 ON T1.District_ID = T2.District_ID WHERE "City_Population" <> 530438.0 OR "Store_ID" <= 1 AND "City_Area" <> 22.0 AND District_name <> "Chiniot District"


Question: What are the driver IDs that are less than 3, and also the driver IDs 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: What driver IDs are both equal to 3 in the driver table and not equal to 10 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 != 10


Question: What are the aircraft IDs that are less than or equal to 4 but not present in the airport aircraft table with IDs greater than or equal to 1?

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 that are greater than or equal to 4, excluding those driver IDs that are greater than 7 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 > 7


Question: What are the driver IDs that are both less than or equal to 8 and also not equal to 9, considering driver IDs from 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 != 9


Question: What are the driver IDs, excluding driver 8, that are present in both the driver and school bus tables, where the school bus driver ID is 9 or greater?

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


Question: What are the aircraft IDs that are less than 5, but not equal to 2, considering only aircraft IDs?

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


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


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

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


Question: What are the IHSAA class, school ID, and school name for schools that meet the following criteria: They are not class AAA and are not named LaVille, or their location is not New Carlisle, or their mascot is Lions and their county is not Starke, or their school ID is not 4; and also meet these criteria: their school ID is not 7, or their name is not Knox Community, or their enrollment is not 605, or their location is not Elkhart and their mascot is Jimmies and their football class is not A and their class is not AAA?

SELECT IHSAA_Class, School_id, School_name FROM School WHERE IHSAA_Class <> "AAA" AND School_name <> "LaVille" OR Location <> "New Carlisle" OR Mascot = "Lions" AND County <> "75 Starke" OR School_id <> "4" INTERSECT SELECT IHSAA_Class, School_id, School_name FROM School WHERE School_id != "7" OR School_name != "Knox Community" AND "Enrollment" != 605 OR County != "50 Marshall" OR Location <> "Elkhart" AND Mascot = "Jimmies" AND IHSAA_Football_Class <> "A" AND IHSAA_Class != "AAA"


Question: What are the shipping agent codes and names for all agents except those with code "AL" or description "t", and also for the agent with code "FE" but not named "UPS"?

SELECT shipping_agent_code, shipping_agent_name FROM Ref_Shipping_Agents WHERE shipping_agent_code != "AL" OR shipping_agent_description != "t" UNION ALL SELECT shipping_agent_code, shipping_agent_name FROM Ref_Shipping_Agents WHERE shipping_agent_code = "FE" AND shipping_agent_name <> "UPS"


Question: For each country, what is the minimum city and the sum of the building numbers, considering addresses in Lake Elaina, or those not in Idaho, or those with building number "9260 Streich Mountain" and zip code "63768", or those with an address ID less than 5? Also, for addresses in West Edmondview with an address ID greater than 3, what is the same information?

SELECT country, MIN(city), SUM(line_1_number_building) FROM Addresses WHERE city = "Lake Elaina" OR state_province_county <> "Idaho" OR line_1_number_building = "9260 Streich Mountain" AND zip_postcode = "63768" OR "address_id" < 5 UNION ALL SELECT country, MIN(city), SUM(line_1_number_building) FROM Addresses WHERE city = "West Edmondview" AND "address_id" > 3


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

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


Question: What are the aircraft IDs greater than 3 that are present in both the aircraft and airport_aircraft tables?

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


Question: Which driver IDs are not equal to 5, but are not in the school bus table with a driver ID of 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: Which driver IDs are equal to 5, or are less than 10 in the school bus table?

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


Question: What are the driver IDs that are greater than 1 and also appear 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 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: What are the driver IDs that are both less than 12 in the driver table and less than 4 in the school bus table?

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


Question: What are the driver IDs that are less than or equal to 12, but not driver IDs less than or equal to 4, considering driver information and school bus information?

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: What are the student IDs of students who belong to a club with an ID greater than 4 and a student ID of 1010 or higher, or who hold a position other than "Teaching Coordinator"? Also, what are the student IDs of students who live in a city other than "WAS", or have an advisor ID less than 5718, or have a last name other than "Smith", or have a major code less than 520 and are 21 years old or younger?

SELECT StuID FROM Member_of_club WHERE "ClubID" > 4 AND "StuID" >= 1010 OR Position != "Teaching Coordinator" UNION ALL SELECT StuID FROM Student WHERE city_code <> "WAS" OR "Advisor" < 5718 OR LName <> "Smith" OR "Major" < 520 AND "Age" <= 21


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: What are the aircraft IDs greater than 1 in the aircraft table, combined with the aircraft IDs less than 3 in the airport_aircraft table?

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


Question: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 3 from the driver table and driver IDs less than 3 from 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 < 3


Question: What is the highest document ID from the Circulation History table where the employee ID is no more than 1, the draft number is 1, and the copy number is 15, combined with the highest document ID from the Documents Mailed table where the mailing date is May 22, 1999, or the document ID is greater than or equal to 12 and the mailed to address ID is less than 5?

SELECT MAX(document_id) FROM Circulation_History WHERE "employee_id" <= 1 AND "draft_number" = 1 AND "copy_number" = 15 UNION SELECT MAX(document_id) FROM Documents_Mailed WHERE mailing_date = "1999-05-22 23:21:07" OR "document_id" >= 12 AND "mailed_to_address_id" < 5


Question: Which driver IDs, up to 8, are in the driver table but not in the school bus table (up to ID 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 are the driver IDs that are either less than or equal to 5 in the driver table or less than 3 in the school bus table?

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


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


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

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


Question: What are the aircraft IDs that are less than 3 and appear in both the aircraft and airport_aircraft tables?

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


Question: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 9 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 <> 9 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


Question: What are the aircraft IDs, excluding aircraft ID 2, from the aircraft table, and also aircraft IDs greater than 2 from the airport_aircraft table?

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


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

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


Question: What are the aircraft IDs that are greater than or equal to 3, excluding those aircraft IDs that are not equal to 5 and are present 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 != 5


Question: Which driver IDs are less than or equal to 8 but not equal to 4, 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 <= 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 4


Question: What are the driver IDs that are not 1 and are in the driver table, but not in the school bus table, excluding driver ID 3?

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


Question: What are the feature and property IDs for properties with an ID greater than 14 or a feature description of "autem" and a feature ID less than 4, along with the feature and property IDs for property 14?

SELECT feature_id, property_id FROM Other_Property_Features WHERE "property_id" > 14 OR property_feature_description = "autem" AND "feature_id" < 4 UNION SELECT feature_id, property_id FROM Other_Property_Features WHERE "property_id" = 14


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


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: What are the mascots of schools that are either Knox Community, not in Marshall County, or don't have an enrollment of 316? Also, what are the mascots of schools that are not Trojans and have an enrollment of 605, or are not in the AAA IHSAA class, or are not LaVille and have a school ID other than 1, or are not located in Knox, or are in Marshall County and not in the AAA IHSAA football class?

SELECT Mascot FROM School WHERE School_name = "Knox Community" OR County != "50 Marshall" OR "Enrollment" != 316 UNION ALL SELECT Mascot FROM School WHERE Mascot != "Trojans" AND "Enrollment" = 605 OR IHSAA_Class != "AAA" OR School_name <> "LaVille" AND School_id != "1" OR Location <> "Knox" OR County = "50 Marshall" AND IHSAA_Football_Class != "AAA"


Question: What are the driver IDs that are less than 7 and also greater than 3, considering only those IDs present in both the driver and school bus tables?

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


Question: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 8 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 <> 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: What are the school types, names, grades, and IDs of schools that have 1st-3rd grade and also have any grade other than 4th grade?

Private Catholic
St. Francis Assisi
1st-3rd grade
2

SELECT Type, School, Grade, School_ID FROM school WHERE Grade = "1st-3rd grade" INTERSECT SELECT Type, School, Grade, School_ID FROM school WHERE Grade <> "4th grade"


Question: Which driver IDs are not equal to 9, but are not found in the school bus table with driver IDs greater than 4?

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


Question: What are the aircraft IDs that are not 3 and also appear in the airport_aircraft table with an ID of 1?

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

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


Question: What are the IDs of staff members who meet all of the following conditions: either their lesson time is 2, or their lesson date is not March 21, 2018, or their staff ID is greater than or equal to 4, or their lesson status is not "Cancelled"; and also meet all of the following conditions: their first name is not Rebekah, or their staff address ID is not 7, or their date of birth is August 10, 2015, or their nickname is "bogisich.geovany" and their date left staff is not March 9, 2018, or their date joined staff is not April 27, 2017 and their middle name is not Liam, and their staff ID is greater than 6?

SELECT staff_id FROM Lessons WHERE lesson_time = "2" OR lesson_date <> "2018-03-21 06:48:45" AND "staff_id" >= 4 OR lesson_status_code <> "Cancelled" INTERSECT SELECT staff_id FROM Staff WHERE first_name <> "Rebekah" AND "staff_address_id" != 7 OR date_of_birth = "2015-08-10 11:37:39" OR nickname = "bogisich.geovany" AND date_left_staff != "2018-03-09 05:08:35" OR date_joined_staff != "2017-04-27 03:21:26" AND middle_name <> "Liam" AND "staff_id" > 6


Question: Which driver IDs, excluding driver ID 5, are present in both the driver and school bus tables, where the driver ID is greater 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: What is the smallest album ID that is 188 or greater, and what is the smallest playlist ID for playlists that are not named "Audiobooks" and have an ID greater than 6?

SELECT MIN(id) FROM albums WHERE "id" >= 188 UNION SELECT MIN(id) FROM playlists WHERE name <> "Audiobooks" AND "id" > 6


Question: What are the aircraft IDs greater than 3, excluding those aircraft IDs that are equal to 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 less than 2 and also appear in the airport aircraft table with IDs no greater than 3?

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


Question: What are the employee IDs, bonuses, and years awarded, either for employees who received a bonus other than in 2016 and a bonus of 4000, or for employee 10, or for employees who are not employee 7, or who received a bonus in 2011?

SELECT Employee_ID, Bonus, Year_awarded FROM evaluation WHERE Year_awarded != "2016" AND "Bonus" = 4000.0 OR Employee_ID = "10" UNION SELECT Employee_ID, Bonus, Year_awarded FROM evaluation WHERE Employee_ID <> "7" OR Year_awarded = "2011"


Question: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 12 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 != 12 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 10


Question: What are the branch IDs of branches not in Oxford, combined with the branch IDs from purchases that are not from branch 2 and not in the year 2018?

SELECT Branch_ID FROM branch WHERE City != "Oxford" UNION ALL SELECT Branch_ID FROM purchase WHERE Branch_ID != "2" AND Year != "2018"


Question: What are the aircraft IDs that are either 3 or greater than 1?

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: What are the driver IDs, excluding driver ID 2, that are present in both the driver and school bus tables, where the driver ID is less than 4 in the school bus table?

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


Question: What are the student IDs of students who either have a pet with an ID less than 2002 or have a student ID less than or equal to 1002, and also the student IDs of students whose advisor ID is greater than 2192, are not male, and whose last name is not Epp and first name is not Sarah, or whose student ID is not 1027?

SELECT StuID FROM Has_Pet WHERE "PetID" < 2002 OR "StuID" <= 1002 UNION SELECT StuID FROM Student WHERE "Advisor" > 2192 AND Sex <> "M" AND LName != "Epp" AND Fname != "Sarah" OR "StuID" != 1027


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


Question: Which driver IDs, excluding ID 1, are present in both the driver and school bus tables, excluding ID 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 driver IDs that are both greater than or equal to 9 in the driver table and greater than or equal to 3 in the school bus table?

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


Question: What are the document and draft numbers for entries where the document ID is greater than 10 or the copy number is less than 5, and also where the document ID is less than 4 and the copy number is no more than 10, or the draft number is 8?

SELECT document_id, draft_number FROM Draft_Copies WHERE "document_id" > 10 OR "copy_number" < 5 INTERSECT SELECT document_id, draft_number FROM Draft_Copies WHERE "document_id" < 4 AND "copy_number" <= 10 OR "draft_number" = 8


Question: What are the aircraft IDs greater than 1 that are not in the list of aircraft IDs that are not equal to 5?

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: What are the driver IDs that are either less than or equal to 5 from the driver table or less than 10 from the school bus table?

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


Question: What are the driver IDs that are greater than or equal to 5, excluding those driver IDs that are not equal to 7?

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


Question: What are the aircraft IDs that are not equal to 5 and are present in the aircraft table but not in the airport_aircraft table, where the airport_aircraft table only includes aircraft IDs greater than 1?

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: Which driver IDs are not equal to 5 and are not present in the school bus table with driver IDs greater than or equal to 3?

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


Question: What are the property type codes for properties that meet a complex set of criteria, excluding those property type codes that are not "Shop"?

SELECT property_type_code FROM Properties WHERE other_property_details != "None" AND "agreed_selling_price" > 4514.807 AND hse_feature_3 = "None" AND "room_count" != 7 AND fld_feature_1 != "None" AND oth_feature_1 != "None" OR property_type_code <> "Shop" AND property_address != "2088 Bashirian Fork Suite 337 Faustinoport, MT 16771-9320" OR date_on_market <> "1990-05-25 23:01:51" AND apt_feature_1 <> "aut" OR apt_feature_3 != "None" OR oth_feature_3 != "None" AND hse_feature_1 != "None" OR shp_feature_1 = "None" OR shp_feature_3 = "None" EXCEPT SELECT property_type_code FROM Ref_Property_Types WHERE property_type_code <> "Shop"


Question: What are the store IDs that meet all of the following conditions: the number of product categories is 1170, the store name isn't Miramichi, the store ID is greater than 2, or the ranking is not 9, or the area size is at least 28.74, or the store type is Village Store, and also have a store ID that is not 2?

SELECT Store_ID FROM store WHERE "Number_of_product_category" = 1170.0 AND Store_Name != "Miramichi" AND "Store_ID" > 2 OR "Ranking" <> 9 OR "Area_size" >= 28.74 OR Type = "Village Store" INTERSECT SELECT Store_ID FROM store_district WHERE "Store_ID" != 2


Question: How many people from Bulgaria, or those who made a final table not equal to 26.0, or those with a best finish of 1.0, or those with a money rank not equal to 68.0, or those not born on April 17, 1987, and with poker player ID 1 and height less than 196.0, are there, grouped by their best finish, where their earnings are 104871.0, or their height is less than 196.0 and their best finish is less than 3.0, or their nationality is not Russia and they were not born on April 17, 1987 and their name is not Maksim Botin, or their final table made is not 42.0 and their poker player ID is greater than or equal to 1?

SELECT COUNT(T1.People_ID), T2.Poker_Player_ID FROM people as T1 JOIN poker_player as T2 ON T1.People_ID = T2.People_ID WHERE Nationality = "Bulgaria" OR "Final_Table_Made" <> 26.0 OR "Best_Finish" = 1.0 OR "Money_Rank" <> 68.0 OR Birth_Date <> "April 17, 1987" AND "Poker_Player_ID" = 1 AND "Height" < 196.0 GROUP BY Best_Finish HAVING Earnings = 104871.0 OR Height < 196.0 AND Best_Finish < 3.0 OR Nationality <> "Russia" AND Birth_Date <> "April 17, 1987" AND Name <> "Maksim Botin" OR Final_Table_Made <> 42.0 AND Poker_Player_ID >= 1


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

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


Question: What are the IDs of drivers who have an ID of 5 or greater and also are assigned to a school bus, excluding driver ID 9?

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


Question: What are the driver IDs, excluding driver ID 11, from the driver table, and also the driver IDs greater than or equal to 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: Which driver IDs are less than 4 or greater than 9, considering driver and school bus information?

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: Which driver IDs are either 10 or not 7, considering driver and school bus information?

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


Question: Which driver IDs, excluding driver ID 1, are in the driver table, and which driver IDs, starting from 9, are in 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 >= 9


Question: What are the majors, last names, first names, student IDs, ages, city codes, sexes, and advisors of students who either have a major code of 600 or higher and an advisor other than 7792, or a last name of Schwartz, or a sex other than male, or a city code other than BAL, and a first name of Sarah and an age of 17, and also have an advisor less than 2311 and a city code other than WAS?

Major LName Fname StuID Age city_code Sex Advisor

SELECT Major, LName, Fname, StuID, Age, city_code, Sex, Advisor FROM Student WHERE "Major" >= 600 AND "Advisor" <> 7792 OR LName = "Schwartz" OR Sex <> "M" OR city_code <> "BAL" AND Fname = "Sarah" AND "Age" = 17 INTERSECT SELECT Major, LName, Fname, StuID, Age, city_code, Sex, Advisor FROM Student WHERE "Advisor" < 2311 AND city_code <> "WAS"


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 IDs 4 or less 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 <= 4


Question: What are the aircraft IDs and names of all aircraft, excluding the "British Aerospace Jetstream 41", and also those with an ID greater than 4, or not named "British Aerospace Jetstream 41"?

SELECT aid, name FROM aircraft WHERE name != "British Aerospace Jetstream 41" UNION SELECT aid, name FROM aircraft WHERE "aid" > 4 OR name <> "British Aerospace Jetstream 41"


Question: Which driver IDs are less than or equal to 4, but not equal to 3, and are 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 <> 3


Question: What are the IDs of all the things that are either certificate with ID 4 or flights that didn't originate in Los Angeles and went to Honolulu, or flights that departed on April 12, 2005 at 7:03 AM, or flights where the distance wasn't 2551 and the price was 780.99 and the flight number was greater than or equal to 2 and the arrival date wasn't April 12, 2005 at 8:45 AM?

SELECT aid FROM certificate WHERE "aid" = 4 UNION SELECT aid FROM flight WHERE origin <> "Los Angeles" AND destination = "Honolulu" OR departure_date = "04/12/2005 07:03" OR "distance" <> 2551 AND "price" = 780.99 AND "flno" >= 2 AND arrival_date != "04/12/2005 08:45"


Question: What are the vehicle IDs that are not equal to 2 or are trucks, but exclude any vehicle IDs that are not trucks?

SELECT vehicle_id FROM Vehicles WHERE "vehicle_id" != 2 OR vehicle_details = "Truck" EXCEPT SELECT vehicle_id FROM Vehicles WHERE vehicle_details <> "Truck"


Question: What are the aircraft IDs, excluding ID 5, that are either in the aircraft table or the airport_aircraft table?

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


Question: What are the driver IDs of drivers with ID 9 or school buses with ID 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: What are the property type descriptions and codes that are either "Field, Meadow." or not "Apartment", and also not "Other, to be determined."?

SELECT property_type_description, property_type_code FROM Ref_Property_Types WHERE property_type_description = "Field, Meadow." OR property_type_code <> "Apartment" INTERSECT SELECT property_type_description, property_type_code FROM Ref_Property_Types WHERE property_type_description <> "Other, to be determined."


Question: What are the aircraft IDs that are less than 5, and also any aircraft IDs that are not equal to 1, considering data from both the aircraft and airport_aircraft tables?

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 driver IDs, excluding driver ID 12, from the driver table, combined with the driver IDs, up to and including 9, from the school bus table?

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


Question: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 5 from the driver table and including only driver IDs greater than or equal to 3 from 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 >= 3


Question: What are the student IDs of students who either have a pet with ID 2001 or higher, or have a student ID of 1001 or lower, but are not students majoring in 100, are not female, and have a last name of Lee, or are not student ID 1003 and do not live in NYC?

SELECT StuID FROM Has_Pet WHERE "PetID" >= 2001 OR "StuID" <= 1001 EXCEPT SELECT StuID FROM Student WHERE "Major" = 100 AND Sex <> "F" AND LName = "Lee" OR "StuID" != 1003 AND city_code = "NYC"


Question: What are the aircraft IDs that are greater than or equal to 1, or any aircraft IDs that are not 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: Which driver IDs are less than 12 but not equal to 3, 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 <> 3


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

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


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

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


Question: What are the driver IDs that are either less than or equal to 4 in the driver table or less than 3 in the school bus table?

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


Question: Which driver IDs are equal to 5, or are present in the school bus table but not equal to 9?

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


Question: What are the aircraft IDs that are equal to 1 but not equal to 5 in the aircraft and airport_aircraft tables respectively?

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: What are the vehicle IDs from lessons that were not cancelled and had a staff ID greater than 11, or that occurred on a date other than February 26, 2018, at 2:36:35 AM and had a lesson ID of 3 or more, excluding any vehicle IDs from vehicles that are not vans and have a vehicle ID of 3?

SELECT vehicle_id FROM Lessons WHERE lesson_status_code != "Cancelled" AND "staff_id" > 11 OR lesson_date <> "2018-02-26 02:36:35" AND "lesson_id" >= 3 EXCEPT SELECT vehicle_id FROM Vehicles WHERE vehicle_details <> "Van" AND "vehicle_id" = 3


Question: Which driver IDs are less than or equal to 1, and which driver ID is 7, considering both drivers and school buses?

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


Question: What are the driver IDs that are not 5 and are also present in the school bus table with a driver ID of 10?

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


Question: What are the driver IDs that are both equal to 9 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 = 9 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 4


Question: What are the shipping agent codes and names for agents whose description is "g" or name is "Ship" or code is not "AL", and also for agents whose code is not "AL" or name is "USPS"?

SELECT shipping_agent_code, shipping_agent_name FROM Ref_Shipping_Agents WHERE shipping_agent_description = "g" OR shipping_agent_name = "Ship" OR shipping_agent_code <> "AL" UNION SELECT shipping_agent_code, shipping_agent_name FROM Ref_Shipping_Agents WHERE shipping_agent_code <> "AL" OR shipping_agent_name = "USPS"


Question: What are the driver IDs, excluding ID 8, from the driver table and the driver IDs, excluding ID 4, from the school bus table?

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


Question: What are the aircraft IDs greater than 5, and also any aircraft IDs that are not equal to 5, considering information from both the aircraft and airport_aircraft tables?

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: Which school IDs meet these criteria: either the school is not in Los Angeles, California, or it doesn't serve 1st-3rd grade, or the school ID is greater than 6 and the school is not private; and also, the school has a bus with a driver ID other than 3, or the bus is full-time, or the school ID is 3 or less?

SELECT School_ID FROM school WHERE Location <> "Los Angeles, California" OR Grade <> "1st-3rd grade" OR "School_ID" > 6 AND Type <> "Private" INTERSECT SELECT School_ID FROM school_bus WHERE "Driver_ID" <> 3 OR If_full_time = "T" OR "School_ID" <= 3


Question: What are the driver IDs that are 8 or greater, excluding those driver IDs that are 7 or less?

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


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

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: What are the driver IDs that are greater than 3 and also appear in the school bus table with driver IDs greater than 9?

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


Question: What are the aircraft IDs that are either greater than or equal to 5 in the aircraft table or not equal to 5 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 != 5


Question: What is the average People ID for people who are 196cm tall, or not from Russia, or have a People ID of 4 or greater? Also, what is the average People ID for poker players whose best finish was greater than 3, and who are not People ID 7, or whose earnings were less than 476090 and Poker Player ID is less than 1 and Money Rank is 141?

SELECT AVG(People_ID) FROM people WHERE "Height" = 196.0 OR Nationality != "Russia" OR "People_ID" >= 4 UNION ALL SELECT AVG(People_ID) FROM poker_player WHERE "Best_Finish" > 3.0 AND "People_ID" != 7 OR "Earnings" < 476090.0 AND "Poker_Player_ID" < 1 AND "Money_Rank" = 141.0


Question: What are the driver IDs that are both greater than or equal to 8 and also equal to 10?

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


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

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


Question: What are the driver IDs from the driver table, where the ID is 1 or greater, combined with the driver IDs from the school bus table, where the ID is 10 or greater?

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


Question: What are the aircraft IDs that are both less than or equal to 4 and not equal to 5, considering only aircraft IDs present in both the aircraft and airport_aircraft tables?

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


Question: What are the aircraft IDs that are either equal to 3 in the aircraft table or less than 3 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 < 3


Question: What are the property type descriptions and codes, excluding "House, Bungalow, etc."?

SELECT property_type_description, property_type_code FROM Ref_Property_Types WHERE property_type_description <> "House, Bungalow, etc." INTERSECT SELECT property_type_description, property_type_code FROM Ref_Property_Types WHERE property_type_description <> "House, Bungalow, etc."


Question: How many features are associated with each property, excluding those described as "odio" or named "Pool", but including those described as "Swimming Pool."?

SELECT COUNT(T1.feature_id), T2.property_id FROM Other_Available_Features as T1 JOIN Other_Property_Features as T2 ON T1.feature_id = T2.feature_id WHERE property_feature_description <> "odio" OR feature_name <> "Pool" OR feature_description = "Swimming Pool."


Question: What is the average draft number for each document, considering drafts up to number 8 from the Document_Drafts table, and also considering all draft numbers except 8 from the Draft_Copies table?

SELECT document_id, AVG(draft_number) FROM Document_Drafts WHERE "draft_number" <= 8 UNION ALL SELECT document_id, AVG(draft_number) FROM Draft_Copies WHERE "draft_number" <> 8


Question: Which driver IDs are either less than or equal to 5, or equal to 4, considering driver and school bus information?

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


Question: Which company IDs don't belong to companies named "Total", or not headquartered in Germany, or not in the "Oil and gas" industry and have sales over 143.7 billion, or have a market value not equal to 107.5 billion, or profits not equal to 14.2 billion, but are not associated with people with ID 1 in the employment records?

SELECT Company_ID FROM company WHERE Name <> "Total" OR Headquarters <> "Germany" OR Industry != "Oil and gas" AND "Sales_in_Billion" > 143.7 OR "Market_Value_in_Billion" <> 107.5 OR "Profits_in_Billion" <> 14.2 EXCEPT SELECT Company_ID FROM employment WHERE "People_ID" = 1


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

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


Question: What are the property IDs that either have a feature other than feature ID 2 or have an apartment feature 3 that is not "None" and feature 2 is "None" or feature 3 is "None" and have at least 2 rooms and a vendor price that is not 661536468.4429 or have an other feature 3 that is not "None"?

SELECT property_id FROM Other_Property_Features WHERE "feature_id" != 2 UNION SELECT property_id FROM Properties WHERE apt_feature_3 <> "None" AND fld_feature_2 = "None" OR fld_feature_3 = "None" AND "room_count" >= 2 AND "vendor_requested_price" <> 661536468.4429 OR oth_feature_3 <> "None"


Question: What are the driver IDs, excluding driver ID 1, from the driver table, combined with driver IDs up to 3 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: What are the driver IDs that are both greater than or equal to 1 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 >= 1 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 4


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

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


Question: Which driver IDs are from drivers who are at least 52 years old or not Democrats and not driver ID 6 and not from East Hartford, or from school buses with school ID 7 or not full-time?

SELECT Driver_ID FROM driver WHERE "Age" >= 52 OR Party != "Dem" AND "Driver_ID" != 6 AND Home_city <> "East Hartford" UNION ALL SELECT Driver_ID FROM school_bus WHERE "School_ID" = 7 OR If_full_time != "T"


Question: What are the aircraft IDs that are either 3 or greater than 5?

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: What are the driver IDs greater than 5 from the driver table, combined with the driver IDs greater than 10 from the school bus table?

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


Question: What are the aircraft IDs greater than 3 that are not present in the airport aircraft table, excluding those with an ID of 2?

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


Question: What are the aircraft IDs that are not 4, but are not present in the airport_aircraft table with an ID of 2?

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 driver IDs are present in both the driver table and the school bus table, excluding driver ID 3, and where the driver ID is less than 6?

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


Question: What are the driver IDs that are less than 12, and also the driver IDs from school buses that are 10 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 >= 10


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

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


Question: What are the maximum profits, the count of headquarters, the sum of company IDs, the count of industries, the count of assets, the average market value, the count of company names, and the sales for each sales value, considering companies where the market value is over 294.7 billion, the headquarters is in the UK, the sales are not 82.6 billion, or the industry is Conglomerate and the company ID is not 7, grouped by sales, excluding groups where the sum of company IDs is 14, the count of headquarters is greater than 1, the count of company names is less than 1 and the maximum profit is at least 16.2, the count of industries is not more than 1, or the count of assets is less than 1? Also, what are the same statistics for companies with a company ID of 17 or more, grouped by sales, but only including groups where the average market value is less than 132.4 billion and the count of industries is not more than 1?

SELECT MAX(Profits_in_Billion), COUNT(Headquarters), SUM(Company_ID), COUNT(Industry), COUNT(Assets_in_Billion), AVG(Market_Value_in_Billion), COUNT(Name), Sales_in_Billion FROM company WHERE "Market_Value_in_Billion" > 294.7 OR Headquarters = "UK" OR "Sales_in_Billion" <> 82.6 OR Industry = "Conglomerate" AND "Company_ID" <> 7.0 GROUP BY Sales_in_Billion HAVING SUM(Company_ID) != 14.0 OR COUNT(Headquarters) > 1 OR COUNT(Name) < 1 AND MAX(Profits_in_Billion) >= 16.2 OR COUNT(Industry) <= 1 OR COUNT(Assets_in_Billion) < 1 UNION SELECT MAX(Profits_in_Billion), COUNT(Headquarters), SUM(Company_ID), COUNT(Industry), COUNT(Assets_in_Billion), AVG(Market_Value_in_Billion), COUNT(Name), Sales_in_Billion FROM company WHERE "Company_ID" >= 17.0 GROUP BY Sales_in_Billion HAVING AVG(Market_Value_in_Billion) < 132.4 AND COUNT(Industry) <= 1


Question: What are the aircraft IDs that are either ID 5 or any ID other than 2, considering both the aircraft and airport_aircraft tables?

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 less than or equal to 8 but not equal to 3, considering only 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 <= 8 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


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

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


Question: What are the aircraft IDs that are not 5 and are in the aircraft table, but not in the airport_aircraft table with an ID of 5?

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


Question: What are the member IDs, registration years, and branch IDs for members in branch 4 for the year 2016, excluding member ID 2, and also for members in branch 6?

SELECT Member_ID, Register_Year, Branch_ID FROM membership_register_branch WHERE Branch_ID = "4" AND Register_Year = "2016" AND "Member_ID" != 2 UNION ALL SELECT Member_ID, Register_Year, Branch_ID FROM membership_register_branch WHERE Branch_ID = "6"


Question: What are the age, ID, minimum weight, and type of pets that either have an ID less than or equal to 2003, weigh less than 9.3, or are dogs, but exclude those that are not dogs?

SELECT pet_age, PetID, MIN(weight), PetType FROM Pets WHERE "PetID" <= 2003 OR "weight" < 9.3 OR PetType = "dog" EXCEPT SELECT pet_age, PetID, MIN(weight), PetType FROM Pets WHERE PetType != "dog"


Question: What is the maximum store ID from the store table where the store ID is not 3, the area size is 28.74, or the type is not "Village Store", or the ranking is at least 2, or the store name is not "Rogersville" and the number of product categories is not 17811? Also, what is the maximum store ID from the store_product table where the product ID is not 1 and the store ID is less than or equal to 5? Then, show only the store IDs that appear in both of these results.

SELECT MAX(Store_ID) FROM store WHERE "Store_ID" <> 3 AND "Area_size" = 28.74 OR Type != "Village Store" OR "Ranking" >= 2 OR Store_Name <> "Rogersville" AND "Number_of_product_category" <> 17811.0 INTERSECT SELECT MAX(Store_ID) FROM store_product WHERE "Product_ID" <> 1 AND "Store_ID" <= 5


Question: Which driver IDs are less than or equal to 4, excluding those that are not equal to 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: What are the driver IDs, excluding driver ID 7, and also the driver IDs greater than 10, 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 > 10


Question: What are the driver IDs, excluding driver ID 11, from the driver table, and also the driver IDs less than 10 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 < 10


Question: What is the smallest percentage of the budget budgeted, excluding values equal to 2.0, for schools with an ID of 4 or higher, and also the smallest percentage of the budget budgeted, excluding values equal to 2.4, for budgets where the budgeted amount is 4979 or less, the invested amount is less than 146102, the year is 2001 or earlier, the school ID is greater than 3, or the budget invested percentage is not 71.3, or the total budget invested percentage is not 2.0?

SELECT MIN(total_budget_percent_budgeted) FROM budget WHERE "total_budget_percent_budgeted" <> 2.0 AND "School_id" >= 4 INTERSECT SELECT MIN(total_budget_percent_budgeted) FROM budget WHERE "total_budget_percent_budgeted" <> 2.4 AND "Budgeted" <= 4979 AND "Invested" < 146102 AND "Year" <= 2001 AND "School_id" > 3 OR Budget_invested_percent != "71.3" OR "total_budget_percent_invested" <> 2.0


Question: What are the aircraft IDs greater than 3 that are not 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 are the ages and head IDs, grouped by age, where the age is not 69 and the name is Dudley Hart, or the department ID is 15, or the born state is not Connecticut, or the temporary acting status is not Yes?

SELECT T1.age, T2.head_ID FROM head as T1 JOIN management as T2 ON T1.head_ID == T2.head_ID GROUP BY age HAVING age <> 69.0 AND name = "Dudley Hart" OR department_ID = 15 OR born_state <> "Connecticut" OR temporary_acting <> "Yes"


Question: What are the club details, including ID, location, description, and name, for clubs that are not the "Tennis Club" or have the description "Venture capital fund for student business." or have a ClubID greater than or equal to 2 and are not located in "HHH", excluding those that are not "Bootup Baltimore" or do not have the description "Refurbish computers; teach kids and adults about computer basics."?

Refurbish computers; teach kids and adults about computer basics.

SELECT ClubID, ClubLocation, ClubDesc, ClubName FROM Club WHERE ClubName != "Tennis Club" OR ClubDesc = "Venture capital fund for student business." OR "ClubID" >= 2 AND ClubLocation != "HHH" EXCEPT SELECT ClubID, ClubLocation, ClubDesc, ClubName FROM Club WHERE ClubName <> "Bootup Baltimore" OR ClubDesc <> "Refurbish computers; teach kids and adults about computer basics."


Question: What states have area code 339, but are not states where votes were cast for a contestant other than number 3, or where the state is not NY, or vote ID is not 2, or the phone number is less than 6209222712, or the vote was not created on March 9, 2018 at 7:03:39 PM?

SELECT state FROM AREA_CODE_STATE WHERE "area_code" = 339 EXCEPT SELECT state FROM VOTES WHERE "contestant_number" <> 3 AND state <> "NY" AND "vote_id" = 2 AND "phone_number" >= 6209222712 OR created <> "2018-03-09 19:03:39"


Question: What are the descriptions and codes of all document types, excluding those with the code "CD"?

SELECT document_type_description, document_type_code FROM Ref_Document_Types WHERE document_type_code != "CD" UNION SELECT document_type_description, document_type_code FROM Ref_Document_Types WHERE document_type_code <> "CD"


Question: What are the driver IDs that are less than 10, and also the driver IDs from school buses that are greater than 3?

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 are present in either the driver table or the school bus table, excluding driver ID 6 from the driver table and driver ID 4 from the school bus table?

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


Question: What are the aircraft IDs that are less than 2, and also the aircraft IDs that are less than or equal to 2, 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 <= 2


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 2 in the aircraft table and greater than or equal to 3 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 >= 3


Question: How many donors are there in the endowment table where the amount is not 9.83, and also how many donors are there where the amount is not 9.83, or the donor's name is not Santiago, or the endowment ID is greater than or equal to 1?

SELECT COUNT(donator_name) FROM endowment WHERE "amount" != 9.83 UNION ALL SELECT COUNT(donator_name) FROM endowment WHERE "amount" <> 9.83 OR donator_name != "Santiago" OR "endowment_id" >= 1


Question: What are the customer IDs, payment method codes, payment dates and times, and payment amounts for payments that were made via direct debit or not equal to 8180.26, and also for payments where the amount was greater than 4773.16, or the customer ID was not 3, and the payment date and time was not 2018-03-12 13:31:36?

SELECT customer_id, payment_method_code, datetime_payment, amount_payment FROM Customer_Payments WHERE payment_method_code = "Direct Debit" OR "amount_payment" != 8180.26 INTERSECT SELECT customer_id, payment_method_code, datetime_payment, amount_payment FROM Customer_Payments WHERE "amount_payment" > 4773.16 OR "customer_id" != 3 AND datetime_payment != "2018-03-12 13:31:36"


Question: What are the invested amounts, the count of total budget percentages budgeted, the sum of budget invested percentages, and the sum of total budget percentages invested, considering either a budgeted value greater than or equal to 3666, or a total budget percentage budgeted not equal to 2.4 and a total budget percentage invested not equal to 2.2, or a year greater than 2004; and also considering a total budget percentage invested not equal to 2.0, or a school ID greater than 2 and a year greater than 2006, all from the budget table?

SELECT Invested, COUNT(total_budget_percent_budgeted), SUM(Budget_invested_percent), SUM(total_budget_percent_invested) FROM budget WHERE "Budgeted" >= 3666 OR "total_budget_percent_budgeted" <> 2.4 AND "total_budget_percent_invested" <> 2.2 OR "Year" > 2004 UNION ALL SELECT Invested, COUNT(total_budget_percent_budgeted), SUM(Budget_invested_percent), SUM(total_budget_percent_invested) FROM budget WHERE "total_budget_percent_invested" != 2.0 OR "School_id" > 2 AND "Year" > 2006


Question: What are the IDs of drivers, excluding driver ID 5, and the IDs of school buses, excluding ID 7?

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


Question: What are the driver IDs less than 3 from the driver table, combined with the driver IDs not equal to 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: Which driver IDs are less than 2 but 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 < 2 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 8, and also the driver IDs that are 10 or greater?

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 are greater than 6 but not less than 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 > 6 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 9


Question: What are the driver IDs, excluding driver ID 11, from the driver table, combined with the driver IDs, starting from ID 3, from the school bus table?

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


Question: What bonus amounts are either less than or equal to 3200 or not from 2015, and also not from 2018, or not given to employee 7, or greater than or equal to 3200?

SELECT Bonus FROM evaluation WHERE "Bonus" <= 3200.0 OR Year_awarded <> "2015" INTERSECT SELECT Bonus FROM evaluation WHERE Year_awarded != "2018" OR Employee_ID <> "7" OR "Bonus" >= 3200.0


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

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


Question: What are the address IDs and details for addresses with IDs greater than 2 and details not equal to "MX", as well as the address with ID 7?

SELECT address_id, address_details FROM Addresses WHERE "address_id" > 2 AND address_details != "MX" UNION SELECT address_id, address_details FROM Addresses WHERE "address_id" = 7


Question: Find the city code, advisor, last name, age, major, sex, student ID, and first name of male students who are not from WAS, and also find the same information for students who are either not male, or whose advisor is not 7134, or whose last name is not Brown.

city_code Advisor LName Age Major Sex StuID Fname

SELECT city_code, Advisor, LName, Age, Major, Sex, StuID, Fname FROM Student WHERE Sex = "M" AND city_code != "WAS" INTERSECT SELECT city_code, Advisor, LName, Age, Major, Sex, StuID, Fname FROM Student WHERE Sex != "M" OR "Advisor" != 7134 OR LName != "Brown"


Question: What are the draft numbers and document IDs from the circulation history where the document ID is not 1, or the employee ID is not 1 and the draft number is 17, or the copy number is greater than 10, but not including those draft numbers and document IDs from the draft copies where the document ID is less than 23, the copy number is greater than 15, and the draft number is greater than 17?

SELECT draft_number, document_id FROM Circulation_History WHERE "document_id" <> 1 OR "employee_id" != 1 AND "draft_number" = 17 OR "copy_number" > 10 EXCEPT SELECT draft_number, document_id FROM Draft_Copies WHERE "document_id" < 23 AND "copy_number" > 15 AND "draft_number" > 17


Question: What are the aircraft IDs that are either aircraft ID 3 or have an aircraft ID greater than 1 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: 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 1 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 >= 1 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 2


Question: Which driver IDs, excluding driver ID 10, are in the driver table, and also which driver IDs, up to and including 4, are 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 <= 4


Question: What are the maker IDs and years of cars where the engine displacement is greater than 156.0 and the acceleration is 11.5, grouped by the full name of the maker?

SELECT T1.Id, T2.Year FROM car_makers as T1 JOIN cars_data as T2 ON T1.Id == T2.Id GROUP BY FullName HAVING Edispl > 156.0 AND Accelerate = 11.5


Question: Which club IDs are from clubs founded after 1998 and not named "Djurgårdens IF", or from match results where the club ID is greater than 2, or where "Big_Silver" is not 6 and the rank is greater than 4?

SELECT Club_ID FROM club WHERE "Start_year" > 1998 AND Club_name <> "Djurgårdens IF" UNION SELECT Club_ID FROM match_result WHERE "Club_ID" > 2 OR "Big_Silver" <> 6 AND "Rank" > 4


Question: What are the template IDs from the Documents table where the other details are not "None" or the document description is "h", combined with the template IDs from the Templates table where the template ID is greater than 0, or the date effective to is not "2008-01-05 14:19:28", or the version number is not 5?

SELECT Template_ID FROM Documents WHERE Other_Details <> "None" OR Document_Description = "h" UNION SELECT Template_ID FROM Templates WHERE "Template_ID" > 0 OR Date_Effective_To <> "2008-01-05 14:19:28" OR "Version_Number" <> 5


Question: Which driver IDs are either less than or equal to 5 and exist in the driver table, or are less than or equal to 3 and exist in the school bus table?

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


Question: Which driver IDs are greater than 12, or are less than or equal to 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: What are the driver IDs that are less than 12 from the driver table, combined with the driver IDs that are 4 or greater from the school bus table?

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


Question: What are the smallest document IDs from the Circulation History table where the copy number isn't 4, or the draft number is less than 20 and the employee ID is at least 8, or the document ID is at least 1? Also, what are the smallest document IDs from the Documents Mailed table where the mailing address ID is 3 and the document ID is 10, or the mailing date was May 27, 1991 at 2:17 PM?

SELECT MIN(document_id) FROM Circulation_History WHERE "copy_number" <> 4 OR "draft_number" < 20 AND "employee_id" >= 8 OR "document_id" >= 1 UNION SELECT MIN(document_id) FROM Documents_Mailed WHERE "mailed_to_address_id" = 3 AND "document_id" = 10 OR mailing_date = "1991-05-27 14:17:37"


Question: What are the driver IDs that are greater than or equal to 2, excluding those driver IDs that are not equal to 3, considering only driver IDs from the driver table and 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 driver IDs that are both less than 10 and also equal to 4, considering driver and school bus information?

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


Question: What are the driver IDs that are either 6 or higher in the driver table, or 9 or higher in the school bus table?

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


Question: Which driver IDs are both less than or equal to 8 and also equal to 4, considering driver and school bus information?

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 are the driver IDs that are greater than or equal to 2 in the driver table, but not driver IDs less than 7 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 < 7


Question: What is the average aircraft ID and the airport ID for aircraft that either have a maximum disk loading of 15 lb/ft², a total disk area of 8,495 ft², a description that is not "Heavy-lift helicopter", an aircraft that is not "Robinson R-22", or a maximum gross weight of 1,370 lb?

SELECT AVG(T1.Aircraft_ID), T2.Airport_ID FROM aircraft as T1 JOIN airport_aircraft as T2 ON T1.Aircraft_ID = T2.Aircraft_ID WHERE Max_disk_Loading = "15 lb/ft² (72 kg/m²)" AND Total_disk_area = "8,495 ft² (789 m²)" OR Description <> "Heavy-lift helicopter" AND Aircraft <> "Robinson R-22" OR Max_Gross_Weight = "1,370 lb (635 kg)"


Question: Show me the student ID, major, and advisor for students where the major is less than or equal to 600, or the sex is female, or the age is less than 17, or the advisor is less than or equal to 9172, or the last name is not Leighton. Also, show me the student ID, major, and advisor for students where the city code is not LOS and the age is not 17, or the major is greater than or equal to 600, or the first name is not Eric.

SELECT StuID, Major, Advisor FROM Student WHERE "Major" <= 600 OR Sex = "F" OR "Age" < 17 OR "Advisor" <= 9172 OR LName <> "Leighton" UNION ALL SELECT StuID, Major, Advisor FROM Student WHERE city_code != "LOS" AND "Age" <> 17 OR "Major" >= 600 OR Fname <> "Eric"


Question: Which driver IDs are equal to 1 but not equal to 4?

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


Question: Which driver IDs are greater than 4 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 > 4 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 3


Question: What are the driver IDs greater than 9 that are present in both the driver and school bus tables, 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: What are the aircraft IDs that are not 3 and are in the aircraft table, but not 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 aircraft IDs that are equal to 4 but not equal to 5 in the airport_aircraft table?

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


Question: Which driver IDs are not equal to 8, and also include driver ID 4, considering both drivers and school buses?

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 are the user IDs of users named Nancy, combined with the user IDs of all users who are not named Helen?

SELECT u_id FROM useracct WHERE name = "Nancy" UNION SELECT u_id FROM useracct WHERE name <> "Helen"


Question: For departments, excluding those named "Treasury" or with a ranking not equal to 13, and also excluding those created in "1903" or with a department ID of 15, give me the count of employees, the maximum ranking, the average department ID, the creation date, and the count of department names, grouped by creation date. Then, show me only the results where the count of employees is not 1. Separately, show me the same information, but only for the departments where the average department ID is 8.0, the maximum ranking is at least 8, or the count of department names is at least 1, or the count of employees is at least 1. Combine these two sets of results.

SELECT COUNT(Num_Employees), MAX(Ranking), AVG(Department_ID), Creation, COUNT(Name) FROM department WHERE Name <> "Treasury" OR "Ranking" != 13 GROUP BY Creation HAVING COUNT(Num_Employees) != 1 UNION SELECT COUNT(Num_Employees), MAX(Ranking), AVG(Department_ID), Creation, COUNT(Name) FROM department WHERE Creation <> "1903" OR "Department_ID" = 15 GROUP BY Creation HAVING AVG(Department_ID) = 8.0 AND MAX(Ranking) >= 8 AND COUNT(Name) >= 1 OR COUNT(Num_Employees) >= 1


Question: What are the aircraft IDs that are not 2, and also what is the aircraft ID 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: What are the IDs of drivers who are not driver ID 1 and are also associated with a school bus with an ID greater than 7?

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


Question: What are the club IDs and average ranks of female coaches with a rank of 5 or less, excluding those club IDs and average ranks found in match results where small silver is not 4, or club ID is 3 or greater, or gold is not 12, or points are less than 66 and big silver is 6 or less?

SELECT Club_ID, AVG(Rank) FROM coach WHERE Gender = "F" AND "Rank" <= 5 EXCEPT SELECT Club_ID, AVG(Rank) FROM match_result WHERE "Small_Silver" <> 4 OR "Club_ID" >= 3 OR "Gold" != 12 OR "Points" < 66 AND "Big_Silver" <= 6


Question: What are the aircraft IDs that are not 1 and also appear in the airport aircraft table with an ID less than 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: What are the aircraft IDs, excluding ID 1, that appear in both the aircraft and airport aircraft tables, with the airport aircraft IDs being no more than 2?

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


Question: What are the driver IDs greater than or equal to 2, excluding driver ID 7?

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


Question: Which club IDs meet these criteria: either they are not located in AKW or their description is not "Play pen and paper games on campus." and their name is "Hopkins Student Enterprises" or their club ID is not 3; or they are club ID 1 and have a student ID greater than or equal to 1010 and the position is CTO?

SELECT ClubID FROM Club WHERE ClubLocation != "AKW" OR ClubDesc <> "Play pen and paper games on campus." AND ClubName = "Hopkins Student Enterprises" OR "ClubID" <> 3 UNION ALL SELECT ClubID FROM Member_of_club WHERE "ClubID" = 1 AND "StuID" >= 1010 AND Position = "CTO"


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

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 IDs of drivers who have an ID greater than 4 and also appear in the school bus table, excluding those with an ID of 9?

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


Question: What are the available features that are not security features and are not BurglarAlarm, but are not available when feature ID is 4 and the feature type is not amenity?

SELECT feature_name FROM Other_Available_Features WHERE feature_type_code <> "Security" AND feature_name != "BurglarAlarm" EXCEPT SELECT feature_name FROM Other_Available_Features WHERE "feature_id" = 4 AND feature_type_code <> "Amenity"


Question: For each committee, what is the average party value, the count of first elected years, and the delegate, counties represented, and election ID? Include results where the first elected year is not 2002, or the delegate is "Malone, James E. Jr. James E. Malone, Jr.", or the party value is less than or equal to 1 and the committee is not "Appropriations". Also include results where the delegate is not "Bobo, Elizabeth Elizabeth Bobo" and the election ID is 6 and the committee is not "Economic Matters" and the party is less than 1, or the first elected year is not 2003.

SELECT Committee, AVG(Party), COUNT(First_Elected), Delegate, Counties_Represented, Election_ID FROM election WHERE "First_Elected" <> 2002.0 OR Delegate = "Malone, James E. Jr. James E. Malone, Jr." OR "Party" <= 1 AND Committee <> "Appropriations" UNION ALL SELECT Committee, AVG(Party), COUNT(First_Elected), Delegate, Counties_Represented, Election_ID FROM election WHERE Delegate <> "Bobo, Elizabeth Elizabeth Bobo" AND "Election_ID" = 6 AND Committee <> "Economic Matters" AND "Party" < 1 OR "First_Elected" != 2003.0


Question: Which driver IDs, excluding ID 12, are present in both the driver and school bus tables, excluding ID 9?

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


Question: What are the driver IDs that are less than or equal to 5, combined with the driver IDs that are not equal to 4?

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


Question: What is the average vehicle ID for lessons where the customer ID is greater than 2 and the vehicle ID is not 2, excluding the average vehicle ID for vehicles with an ID of 2 or less?

SELECT AVG(vehicle_id) FROM Lessons WHERE "customer_id" > 2 AND "vehicle_id" <> 2 EXCEPT SELECT AVG(vehicle_id) FROM Vehicles WHERE "vehicle_id" <= 2


Question: What are the driver IDs that are either greater than or equal to 3 from the driver table, or not equal to 7 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 != 7


Question: Which driver IDs are not equal to 4 but are not found in school buses with driver IDs greater than or equal to 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, excluding driver ID 6, and also the driver IDs from school buses that are 3 or greater?

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


Question: What are the other details for employees named Koby or those whose role isn't PR, and also the other details for employees who aren't Clemens and have "b" as other details, provided their employee ID is greater than 1?

SELECT other_details FROM Employees WHERE employee_name = "Koby" OR role_code <> "PR" UNION ALL SELECT other_details FROM Employees WHERE employee_name <> "Clemens" AND other_details = "b" AND "employee_id" > 1


Question: Which aircraft IDs are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 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 branch and member IDs of members with IDs greater than 5 in the membership register, excluding those who made purchases in years other than 2017?

SELECT Branch_ID, Member_ID FROM membership_register_branch WHERE "Member_ID" > 5 EXCEPT SELECT Branch_ID, Member_ID FROM purchase WHERE Year <> "2017"


Question: Which driver IDs are greater than 3, excluding those with an ID of 3, considering only 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 = 3


Question: What are the IDs of albums that are not album ID 178 or not titled "Use Your Illusion II", combined with the IDs of employees who are from Canada, or whose birth date is not "1958-12-08", and last name is "Adams", or report to employee ID 6, or live in Calgary, or have a different fax number than "+1 (403) 467-8772", or a different postal code than "T3B 0C5" and a different phone number than "1 (780) 836-9987", or a different state than "AB", or were hired on "2003-10-17" and have a different email than "nancy@chinookcorp.com"?

SELECT id FROM albums WHERE "id" <> 178 OR title != "Use Your Illusion II" UNION ALL SELECT id FROM employees WHERE country = "Canada" OR birth_date != "1958-12-08 00:00:00" AND last_name = "Adams" OR "reports_to" = 6.0 OR city = "Calgary" OR fax != "+1 (403) 467-8772" OR postal_code != "T3B 0C5" AND phone != "1 (780) 836-9987" OR state <> "AB" OR hire_date = "2003-10-17 00:00:00" AND email <> "nancy@chinookcorp.com"


Question: Which driver IDs are either 11 or greater than or equal to 4?

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

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: What are the document IDs and descriptions for documents that either aren't named "Learning French", have a template ID of 21 or higher, have other details that aren't "None", or have a document ID of 3830? Also, include the document IDs and descriptions for documents where the description is "w", the name isn't "Summer Show", the document ID is less than 3, the template ID is 6 or less, or the other details aren't "None".

SELECT Document_ID, Document_Description FROM Documents WHERE Document_Name <> "Learning French" OR "Template_ID" >= 21 OR Other_Details != "None" OR "Document_ID" = 3830 UNION ALL SELECT Document_ID, Document_Description FROM Documents WHERE Document_Description = "w" OR Document_Name != "Summer Show" OR "Document_ID" < 3 OR "Template_ID" <= 6 OR Other_Details != "None"


Question: What are the driver IDs that are both greater than or equal to 3 in the driver table and greater than or equal to 4 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 >= 4


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

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 aircraft IDs, excluding aircraft ID 4, from the aircraft table, combined with aircraft IDs greater than or equal to 1 from the airport_aircraft table?

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


Question: What are the IDs of people who either work at a company with an ID greater than 17 or have an ID less than or equal to 1, combined with the IDs of people whose ID is at least 1 and whose nationality is not United States, or whose graduation college is not Northeastern, or whose age is 25?

SELECT People_ID FROM employment WHERE "Company_ID" > 17 OR "People_ID" <= 1 UNION SELECT People_ID FROM people WHERE "People_ID" >= 1 AND Nationality <> "United States" OR Graduation_College != "Northeastern" OR "Age" = 25


Question: What are the aircraft IDs that are not equal to 4, but are not present in the airport aircraft table with IDs greater than 2?

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 driver IDs are less than or equal to 8 and are in the driver table but not in the school bus table, where the driver IDs in the school bus table are less than 9?

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


Question: What are the document IDs that are less than 2 and not associated with employee ID 1, combined with the document IDs from documents that have a shipping agent code other than AL and are not overdue, or were received on November 5, 1985 at 17:59:34, or have other details as "j", or have a receipt number different from "93", or have a document ID different from 20?

SELECT document_id FROM Circulation_History WHERE "document_id" < 2 AND "employee_id" <> 1 UNION ALL SELECT document_id FROM Documents WHERE shipping_agent_code <> "AL" AND document_status_code != "overdue" OR receipt_date = "1985-11-05 17:59:34" OR other_details = "j" OR receipt_number <> "93" OR "document_id" <> 20


Question: What are the driver IDs, excluding driver ID 7, and also the driver IDs less than 3?

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 are the driver IDs, excluding driver ID 6, and also the driver IDs greater than 10, considering both driver and school bus information?

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


Question: What are the school IDs of schools that are not in Honolulu, Hawaii and not 4th grade and have a school ID of 3 or greater, and also are either private schools with a school ID less than 6 or not in 1st-3rd grade?

SELECT School_ID FROM school WHERE Location != "Honolulu, Hawaii" AND Grade != "4th grade" AND "School_ID" >= 3 INTERSECT SELECT School_ID FROM school WHERE Type = "Private" AND "School_ID" < 6 OR Grade != "1st-3rd grade"


Question: What are the driver IDs that are either 6 or less than or equal to 10?

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


Question: Which aircraft IDs are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 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 copy and draft numbers where the copy number is 5 or greater, the document ID is less than 2, or the draft number is greater than 2? Also, what are the copy and draft numbers where the document ID is 10 or greater, the draft number is not 17, or the copy number is 10?

SELECT copy_number, draft_number FROM Draft_Copies WHERE "copy_number" >= 5 OR "document_id" < 2 OR "draft_number" > 2 UNION ALL SELECT copy_number, draft_number FROM Draft_Copies WHERE "document_id" >= 10 OR "draft_number" <> 17 OR "copy_number" = 10


Question: What are the document IDs from the Documents table that are not "q" in other details, not "FE" in shipping agent code, or not "55" in receipt number, or not 25 as document ID, and have a receipt date of April 17, 1999, and are of type "Paper", along with the document IDs from the Documents_Mailed table where the mailed to address ID is 7 or greater?

SELECT document_id FROM Documents WHERE other_details != "q" AND shipping_agent_code != "FE" OR receipt_number != "55" OR "document_id" != 25 AND receipt_date = "1999-04-17 14:19:32" AND document_type_code = "Paper" UNION SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" >= 7


Question: What are the driver IDs that are less than 1, combined with the driver IDs that are less than or equal to 9?

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


Question: What are the aircraft IDs that are not equal to 1 and also appear in the airport aircraft table with an ID greater than or equal to 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: What are the driver IDs that are less than 11 from the driver table, combined with the driver IDs that are 10 or greater 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 >= 10


Question: What are the driver IDs that are both greater than or equal to 10 in the driver table and equal to 10 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 = 10


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


Question: What are the template details, effective from date, template type code, version number, template ID, and effective to date for templates with ID 6 and an effective from date not equal to July 16, 1983, or for templates where the effective to date is not December 7, 1994, or the effective from date is June 21, 1999?

SELECT Template_Details, Date_Effective_From, Template_Type_Code, Version_Number, Template_ID, Date_Effective_To FROM Templates WHERE "Template_ID" = 6 AND Date_Effective_From <> "1983-07-16 21:16:16" UNION ALL SELECT Template_Details, Date_Effective_From, Template_Type_Code, Version_Number, Template_ID, Date_Effective_To FROM Templates WHERE Date_Effective_To != "1994-12-07 13:26:23" OR Date_Effective_From = "1999-06-21 11:10:30"


Question: Which driver IDs are present in both the driver table (excluding driver ID 2) and the school bus table (excluding driver ID 3)?

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


Question: How many schools meet the following criteria: their mascot isn't "Lancers" and they are in IHSAA Class "AA", or their name isn't "Knox Community", their ID isn't "6", they are in IHSAA Football Class "AAA" and their county isn't "46 LaPorte 71 St. Joseph", or their location isn't "Bremen" and their enrollment isn't 379? Also, how many budget entries meet these conditions: the percentage of the budget invested isn't "71.3", or the school ID is less than 2, or the year is before 2003 and the total budget invested percentage is 2.0?

SELECT COUNT(School_id) FROM School WHERE Mascot <> "Lancers" AND IHSAA_Class = "AA" OR School_name != "Knox Community" AND School_id <> "6" AND IHSAA_Football_Class = "AAA" AND County != "46 LaPorte 71 St. Joseph" OR Location != "Bremen" AND "Enrollment" <> 379 UNION SELECT COUNT(School_id) FROM budget WHERE Budget_invested_percent != "71.3" OR "School_id" < 2 OR "Year" < 2003 AND "total_budget_percent_invested" = 2.0


Question: What is the maximum airport ID and the corresponding aircraft ID, based on the airport and airport_aircraft tables?

SELECT MAX(T1.Airport_ID), T2.Aircraft_ID FROM airport as T1 JOIN airport_aircraft as T2 ON T1.Airport_ID = T2.Airport_ID