Question: Which aircraft IDs are either 1 or less than or equal to 3, considering both aircraft and airport-aircraft data?

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


Question: What are the IDs of drivers, excluding driver 6, and the IDs of school bus drivers, excluding driver 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 aircraft IDs, excluding ID 1, that are present in both the aircraft and airport_aircraft tables?

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


Question: What are the driver IDs that are both less than 12 and also greater than or equal to 4, considering only driver IDs present in both the 'driver' and 'school_bus' tables?

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 shipping agent codes from the Documents table that are not "FE" and were not received on "2015-04-03 09:36:19", or have a document type other than "CD" and a document status other than "overdue", or have other details not equal to "q" and a document ID less than 13 and a receipt number of "34", and also appear in the Ref_Shipping_Agents table with a description other than "t", or a code other than "UP" and a name of "UPS"?

SELECT shipping_agent_code FROM Documents WHERE shipping_agent_code <> "FE" AND receipt_date != "2015-04-03 09:36:19" OR document_type_code != "CD" AND document_status_code <> "overdue" OR other_details != "q" AND "document_id" < 13 AND receipt_number = "34" INTERSECT SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_description <> "t" OR shipping_agent_code != "UP" AND shipping_agent_name = "UPS"


Question: Which employee IDs are present in the certificate table but not associated with employee ID 141582651, and also have a salary of 256481, an ID greater than or equal to 556784565, and a name that isn't William Moore?

SELECT eid FROM certificate WHERE "eid" != 141582651 INTERSECT SELECT eid FROM employee WHERE "salary" = 256481 AND "eid" >= 556784565 AND name != "William Moore"


Question: Which aircraft IDs are not equal to 1, and which aircraft IDs are greater than 5, considering both aircraft and airport aircraft data?

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 aircraft IDs that are less than 3 in the aircraft table, combined with aircraft IDs from the airport_aircraft table that are not equal to 2?

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


Question: What are the different grades offered, excluding those in college, or not from State Elementary School Menteng 01? Also, what are the grades offered excluding those from Occidental College and Jakarta, Indonesia, or where the school ID isn't 5 and the grade isn't 5th-12th grade, or the school isn't private?

SELECT Grade FROM school WHERE Grade != "College" OR School <> "State Elementary School Menteng 01" UNION SELECT Grade FROM school WHERE School != "Occidental College" AND Location != "Jakarta, Indonesia" OR "School_ID" <> 5 AND Grade != "5th-12th grade" OR Type <> "Private"


Question: Which driver IDs are greater than 4 and also appear in the school bus table with a driver 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 aircraft IDs that are both less than or equal to 3 and also greater than 2, considering only those aircraft IDs 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 > 2


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

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


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


Question: What are the driver IDs greater than 7, combined with the driver IDs from school buses that are not equal to 4?

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


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

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


Question: What are the driver IDs that are greater than or equal to 2, excluding those driver IDs that are less than or equal to 3?

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


Question: What car models are from makes with an ID greater than 279 or are named "amc", but not models with an ID less than 16 or that aren't "mercedes" and have a maker value less than or equal to 19?

SELECT Model FROM car_names WHERE "MakeId" > 279 OR Model = "amc" EXCEPT SELECT Model FROM model_list WHERE "ModelId" < 16 OR Model <> "mercedes" AND "Maker" <= 19


Question: Which driver IDs are greater than 6, and also include driver ID 7?

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


Question: Which driver IDs are less than or equal to 6, but not equal to 9, considering only the drivers and school buses?

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


Question: What is the total sum of document IDs from the Circulation History table where the draft number is not 17 or the employee ID is less than 1, combined with the total sum of document IDs from the Documents Mailed table where the mailing date is not "1992-11-07 15:03:41", or the mailed to address ID is not 8, or the document ID is not 2?

SELECT SUM(document_id) FROM Circulation_History WHERE "draft_number" <> 17 OR "employee_id" < 1 UNION ALL SELECT SUM(document_id) FROM Documents_Mailed WHERE mailing_date <> "1992-11-07 15:03:41" OR "mailed_to_address_id" != 8 OR "document_id" <> 2


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

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


Question: What are the driver IDs greater than 11 from the driver table, combined with the driver IDs less than 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 are the driver IDs that are in the driver table but not in the school bus table, excluding driver ID 6 from the driver table and driver ID 9 from the school bus table?

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


Question: What are the ranks of match results where Big_Silver is at least 11 or Bronze is 8 and Points is 89, excluding the ranks of players who are not Ross C. Martin or whose occupation is not Researcher and have 9506 votes or whose rank is not 1st?

SELECT Rank FROM match_result WHERE "Big_Silver" >= 11 OR "Bronze" = 8 AND "Points" = 89 EXCEPT SELECT Rank FROM player WHERE Player_name != "Ross C. Martin" OR Occupation <> "Researcher" AND "Votes" = 9506 OR Rank <> "1st"


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

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


Question: Which customer IDs made payments of at least 4610.26 or have a customer ID less than 13 and the payment wasn't on March 12, 2018 at 08:41:47, or had lessons with a price greater than 223.0, at lesson time 9, with a staff ID of 8 or less, or the lesson date wasn't March 12, 2018 at 00:41:59?

SELECT customer_id FROM Customer_Payments WHERE "amount_payment" >= 4610.26 OR "customer_id" < 13 AND datetime_payment <> "2018-03-12 08:41:47" UNION SELECT customer_id FROM Lessons WHERE "price" > 223.0 AND lesson_time = "9" AND "staff_id" <= 8 OR lesson_date != "2018-03-12 00:41:59"


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

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


Question: What are the IDs of drivers, excluding driver ID 4, who are also assigned to a school bus, also excluding driver ID 4?

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


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

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


Question: What are the IDs of drivers who are not driver ID 2 and also have driver ID 3 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 = 3


Question: What are the IDs of car makers that are not ID 15, or from country 8 and not Volvo, or not subaru, and also have an acceleration not equal to 15.4, or horsepower not equal to 170, or a weight of 3613 and an engine displacement of 225.0, or an MPG of 10, or an ID greater than or equal to 97 and a year not equal to 1973?

SELECT Id FROM car_makers WHERE "Id" != 15 OR Country = "8" AND FullName <> "Volvo" OR Maker != "subaru" INTERSECT SELECT Id FROM cars_data WHERE "Accelerate" <> 15.4 AND Horsepower != "170" OR "Weight" = 3613 AND "Edispl" = 225.0 OR MPG = "10" OR "Id" >= 97 AND "Year" != 1973


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

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


Question: What is the maximum state value from the AREA_CODE_STATE table where the state is MI, combined with the maximum state value from the VOTES table where the state is not NY and either the vote ID is greater than 5, the phone number is not 5112677315, or the contestant number is greater than or equal to 5 and the creation date is March 9, 2018 at 7:03:21 PM?

SELECT MAX(state) FROM AREA_CODE_STATE WHERE state = "MI" UNION SELECT MAX(state) FROM VOTES WHERE state != "NY" AND "vote_id" > 5 OR "phone_number" <> 5112677315 OR "contestant_number" >= 5 AND created = "2018-03-09 19:03:21"


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

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


Question: What are the names, descriptions, and types of features that are not described as "Swimming Pool" or have a feature ID other than 2 and are not amenities, combined with features that are not amenities?

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


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

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 aircraft IDs greater than 2, and also any aircraft IDs that are not 3, 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 != 3


Question: Which driver IDs, excluding driver ID 4, are present in the driver table, and which driver IDs, excluding driver ID 9, are present 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 <> 9


Question: What are the car models that are not "plymouth" or have a "MakeId" of 324, combined with the models where the "ModelId" is 12 or the model is not "renault" and the "Maker" is not 8?

SELECT Model FROM car_names WHERE Model <> "plymouth" OR "MakeId" = 324 UNION SELECT Model FROM model_list WHERE "ModelId" = 12 OR Model <> "renault" AND "Maker" != 8


Question: Which driver IDs are not equal to 1 but are not present in the school bus table with a driver ID of 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: Which club IDs are associated with male coaches with club IDs greater than 3, or with match results where the gold medal count isn't 5 or the big silver medal count isn't 6 and the rank isn't 4?

SELECT Club_ID FROM coach WHERE Gender = "M" AND "Club_ID" > 3 UNION ALL SELECT Club_ID FROM match_result WHERE "Gold" <> 5 OR "Big_Silver" <> 6 AND "Rank" != 4


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

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


Question: What are the aircraft IDs that are either greater than or equal to 4 in the aircraft table, or less than or equal to 5 in the airport_aircraft table?

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


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


Question: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 2 from the driver table and including only driver IDs up to 10 from 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 <= 10


Question: What are the aircraft IDs that are not 2 and also appear in the airport aircraft table, excluding aircraft ID 3?

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


Question: How many versions are there for each template ID where the version number is greater than 5 and the template ID is not 10, or the effective date from is not "1986-12-09 14:51:36" and the effective date to is "1980-05-07 12:15:47", excluding the cases where the effective date from is not "2002-03-02 14:39:49"?

SELECT COUNT(Version_Number), Template_ID FROM Templates WHERE "Version_Number" > 5 AND "Template_ID" != 10 OR Date_Effective_From != "1986-12-09 14:51:36" AND Date_Effective_To = "1980-05-07 12:15:47" EXCEPT SELECT COUNT(Version_Number), Template_ID FROM Templates WHERE Date_Effective_From != "2002-03-02 14:39:49"


Question: Which player IDs belong to players ranked 1st, are female, don't live in Winnipeg, have a player ID greater than 4, aren't researchers, or have 4914 votes, and also which player IDs are from coaches who started in or after 2010 or have a coach ID of 3 or less?

SELECT Player_ID FROM player WHERE Rank = "1st" OR Gender = "F" OR Residence != "Winnipeg" OR "Player_ID" > 4 OR Occupation != "Researcher" OR "Votes" = 4914 UNION ALL SELECT Player_ID FROM player_coach WHERE "Starting_year" >= 2010 OR "Coach_ID" <= 3


Question: What are the driver IDs, excluding driver ID 4, that are present in both the driver and school bus tables, where the driver ID is less than 9 in the school bus table?

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 student IDs of students with IDs less than 1002 and pet IDs less than 2002, along with the student IDs of students who are not 20 years old?

SELECT StuID FROM Has_Pet WHERE "StuID" < 1002 AND "PetID" < 2002 UNION ALL SELECT StuID FROM Student WHERE "Age" <> 20


Question: What are the driver IDs that appear in both the driver and school bus tables, where the driver ID is at least 1 in the driver table and at most 7 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 <= 7


Question: What are the driver IDs, excluding driver ID 6, and also driver ID 7?

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


Question: What are the driver IDs that are present in both the driver table (excluding driver ID 1) and the school bus table (with driver IDs less than 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 student IDs and ages of male students who are also either not named Jones, over 19 years old, or have a major less than 520?

SELECT StuID, Age FROM Student WHERE Sex = "M" INTERSECT SELECT StuID, Age FROM Student WHERE LName <> "Jones" AND "Age" > 19 OR Sex = "M" OR "Major" < 520


Question: Which driver IDs are either less than or equal to 11 from the driver table or not equal to 9 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 <> 9


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


Question: Which driver IDs are less than 6 but not equal to 10, 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 = 10


Question: Which driver IDs are greater than or equal to 1 but not equal to 9, considering only those 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 >= 1 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 9


Question: Which driver IDs are greater than 3 and also less than 7, 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 > 3 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 7


Question: What is the minimum city population, the headquartered city, the average city area, and the district name for districts where the district ID is greater than 1 or the district name is Faisalabad District, and the city population is 134936.0, the headquartered city is Attock City, and the city area is less than 147.0? Also, what is the minimum city population, the headquartered city, the average city area, and the district name for districts where the city population is less than 94620.0, the district ID is 12, and the city area is not 25.0?

SELECT MIN(City_Population), Headquartered_City, AVG(City_Area), District_name FROM district WHERE "District_ID" > 1 OR District_name = "Faisalabad District" AND "City_Population" = 134936.0 AND Headquartered_City = "Attock City" AND "City_Area" < 147.0 UNION ALL SELECT MIN(City_Population), Headquartered_City, AVG(City_Area), District_name FROM district WHERE "City_Population" < 94620.0 AND "District_ID" = 12 AND "City_Area" != 25.0


Question: Which driver IDs are either less than or equal to 6 in the driver table or greater than 3 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 > 3


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

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


Question: Which driver IDs are not equal to 4 and are not 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 != 4 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: What are the draft numbers and document IDs from the Document Drafts table where the draft details aren't "k" and the draft number is 4 or greater, combined with the draft numbers and document IDs from the Draft Copies table where the draft number is less than 2?

SELECT draft_number, document_id FROM Document_Drafts WHERE draft_details != "k" AND "draft_number" >= 4 UNION ALL SELECT draft_number, document_id FROM Draft_Copies WHERE "draft_number" < 2


Question: Which driver IDs are equal to 6, or are driver IDs from school buses 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: What are the driver IDs, excluding driver ID 11, from the driver table, combined with the 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 != 11 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 3


Question: What are the school IDs for schools that are either AAA football class, or have a mascot that isn't Trojans and don't have an enrollment of 852 or have a school name that isn't Triton, combined with the school IDs from budgets where the invested amount is over 85249, or the total budget percent budgeted is at least 2.0 and the budget invested percent isn't 146.9, or the budgeted amount is over 113531?

SELECT School_id FROM School WHERE IHSAA_Football_Class = "AAA" OR Mascot <> "Trojans" AND "Enrollment" != 852 OR School_name != "Triton" UNION SELECT School_id FROM budget WHERE "Invested" > 85249 OR "total_budget_percent_budgeted" >= 2.0 AND Budget_invested_percent != "146.9" OR "Budgeted" > 113531


Question: Give me the creation date, phone number, and vote ID for all votes that were not from New York and were not created at "2018-03-09 19:03:40", along with the creation date, phone number, and vote ID for votes that were not created at "2018-03-09 19:03:36", or had a phone number greater than or equal to 7182887233, or had a vote ID less than 3, or were not from New Jersey and did not have a contestant number of 2.

SELECT created, phone_number, vote_id FROM VOTES WHERE state != "NY" AND created != "2018-03-09 19:03:40" UNION ALL SELECT created, phone_number, vote_id FROM VOTES WHERE created <> "2018-03-09 19:03:36" OR "phone_number" >= 7182887233 OR "vote_id" < 3 OR state != "NJ " AND "contestant_number" != 2


Question: What are the different document status codes for documents received on November 5, 1985, at 5:59:34 PM, or those that are not of type "CD", or those that don't have a "working" status, or have a receipt number other than "189", or are not shipped by "AL" and have a document ID greater than or equal to 25? Also, what are the document status codes that are not "overdue"? Combine these two sets of document status codes.

SELECT document_status_code FROM Documents WHERE receipt_date = "1985-11-05 17:59:34" OR document_type_code != "CD" OR document_status_code != "working" OR receipt_number <> "189" OR shipping_agent_code <> "AL" AND "document_id" >= 25 UNION SELECT document_status_code FROM Ref_Document_Status WHERE document_status_code <> "overdue"


Question: What are the driver IDs greater than 10, excluding those driver IDs that are less than 7?

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


Question: What are the document IDs that either don't have a receipt number of "117" or were mailed to an address other than ID 8?

SELECT document_id FROM Documents WHERE receipt_number != "117" UNION ALL SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" <> 8


Question: Which driver IDs are greater than 9 but not equal to 10, considering only those IDs present in the driver table and excluding those in the school bus table?

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


Question: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 3 from the driver table and including driver IDs up to 4 from 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: Which driver IDs are less than or equal to 8, and also include driver ID 9?

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


Question: 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 aircraft IDs greater than 3 that are not present in the airport aircraft table, excluding those with an ID of 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: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 4, and with all driver IDs being greater than or equal to 1?

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 aircraft IDs that are less than or equal to 4, excluding those aircraft IDs that are not equal to 2, considering only the aircraft and airport_aircraft tables?

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


Question: What are the names of aircraft with an ID greater than 16 and a distance of 4103 or less that are SAAB 340, combined with the names of employees who are not Elizabeth Taylor or whose salary is not 227489?

SELECT name FROM aircraft WHERE "aid" > 16 AND "distance" <= 4103 AND name = "SAAB 340" UNION ALL SELECT name FROM employee WHERE name <> "Elizabeth Taylor" OR "salary" <> 227489


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


Question: What are the names of Lockheed L1011 aircraft with a distance of at least 2605, and also the names of employees who don't earn $114323 and aren't named Karen Scott, or whose employee ID is greater than 159542516?

SELECT name FROM aircraft WHERE "distance" >= 2605 AND name = "Lockheed L1011" UNION SELECT name FROM employee WHERE "salary" != 114323 AND name != "Karen Scott" OR "eid" > 159542516


Question: Give me the people's IDs, birth dates, heights, and nationalities of people born on August 8, 1986, who are not 182.0 tall or are not Russian, excluding those born on August 16, 1982, who are taller than 193.0 and are not Bulgarian.

SELECT People_ID, Birth_Date, Height, Nationality FROM people WHERE Birth_Date = "August 8, 1986" AND "Height" != 182.0 OR Nationality != "Russia" AND "People_ID" <> 7 EXCEPT SELECT People_ID, Birth_Date, Height, Nationality FROM people WHERE Birth_Date = "August 16, 1982" AND "Height" > 193.0 AND Nationality <> "Bulgaria"


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

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


Question: What are the aircraft IDs less than 4, and also what are the aircraft IDs that are not 2, considering both the aircraft and airport_aircraft tables?

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 other details from documents where the receipt date is not "1985-11-05 17:59:34", or the shipping agent code is "UP" and the document status code is "working" and the document ID is less than or equal to 10, excluding the other details from employees where the employee ID is 8, or the role code is not "MG" and the employee name is not "Clemens", or the other details are not "v"?

SELECT other_details FROM Documents WHERE receipt_date <> "1985-11-05 17:59:34" OR shipping_agent_code = "UP" AND document_status_code = "working" AND "document_id" <= 10 EXCEPT SELECT other_details FROM Employees WHERE "employee_id" = 8 OR role_code != "MG" AND employee_name <> "Clemens" OR other_details != "v"


Question: What are the names of donors and the amounts they donated, along with the highest endowment ID, where the donation amount is less than or equal to 9.83, and also where the donation amount is less than or equal to 8.33 and the school ID is not 3?

SELECT donator_name, amount, MAX(endowment_id) FROM endowment WHERE "amount" <= 9.83 INTERSECT SELECT donator_name, amount, MAX(endowment_id) FROM endowment WHERE "amount" <= 8.33 AND "School_id" <> 3


Question: How many property feature descriptions are there where the feature ID is 3 or less and not "earum", combined with the count of property feature descriptions where the property ID is greater than 15?

SELECT COUNT(property_feature_description) FROM Other_Property_Features WHERE "feature_id" <= 3 AND property_feature_description <> "earum" UNION SELECT COUNT(property_feature_description) FROM Other_Property_Features WHERE "property_id" > 15


Question: Which driver IDs are greater than or equal to 9, but not present 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 greater than or equal to 4, excluding those aircraft IDs that are less than 2 in the airport aircraft table?

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


Question: What are the aircraft IDs, excluding aircraft ID 5, and also the aircraft IDs that are 5 or less, 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 <= 5


Question: What are the driver IDs that are greater than or equal to 4, but not including any driver IDs that are less than or equal to 7?

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 less than or equal to 2, or the driver IDs that are greater than or equal to 3?

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


Question: What is the sum of Club IDs and the student IDs for clubs where the president is not in "Hopkins Student Enterprises", grouped by club name, and where the club description is not "Refurbish computers; teach kids and adults about computer basics." or the number of students is less than or equal to 1007?

SELECT SUM(T1.ClubID), T2.StuID FROM Club as T1 JOIN Member_of_club as T2 ON T1.ClubID = T2.ClubID WHERE Position = "President" AND ClubName <> "Hopkins Student Enterprises" GROUP BY ClubName HAVING ClubDesc <> "Refurbish computers; teach kids and adults about computer basics." OR Position = "President" AND COUNT(StuID) <= 1007


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

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


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

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


Question: What is the average age of employees and the year they were awarded, specifically for the year 2015 in Sale, or for any employee whose name is not Jason Hobson, grouped by city, excluding results where the name is Matt Stevens?

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


Question: Which driver IDs are greater than 5, and also include driver 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 that are less than or equal to 1, excluding those driver IDs that are less than 10?

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


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

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


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

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


Question: What are the draft numbers and document IDs from the Document Drafts table where the draft details aren't "w" and the document ID is 17, or the draft number is greater than 0? Also, what are the draft numbers and document IDs from the Draft Copies table where the document ID is 2 or greater? Combine all these results.

SELECT draft_number, document_id FROM Document_Drafts WHERE draft_details <> "w" AND "document_id" = 17 OR "draft_number" > 0 UNION ALL SELECT draft_number, document_id FROM Draft_Copies WHERE "document_id" >= 2


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

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


Question: What are the aircraft IDs that are greater than or equal to 2, but not present in the airport aircraft table with IDs less than or equal to 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 aircraft IDs that are greater than or equal to 1 in the aircraft table, but not present in the airport_aircraft table with IDs greater than 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: 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 9 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 <> 9


Question: What are the driver IDs greater than 2, 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 > 2 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


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


Question: What are the driver IDs greater than 6 that are present in both the driver and school bus tables, excluding driver ID 10?

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


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

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


Question: What are the driver IDs that are less than 7 from the driver table, combined with the driver IDs that are less than or equal to 4 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 <= 4


Question: Which aircraft have an ID of 3 and are listed 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: How many budgeted items and years are there, along with the budget invested percentage and total budget invested percentage, where the total budget invested percentage is at least 2.7? Also, how many budgeted items and years are there, along with the budget invested percentage and total budget invested percentage, where the year is not 2003 or the school ID is at least 4 and the budgeted amount is 113531 and the invested amount is not 5840 and the total budget invested percentage is less than or equal to 2.0?

SELECT COUNT(Budgeted), COUNT(Year), Budget_invested_percent, total_budget_percent_invested FROM budget WHERE "total_budget_percent_invested" >= 2.7 UNION ALL SELECT COUNT(Budgeted), COUNT(Year), Budget_invested_percent, total_budget_percent_invested FROM budget WHERE "Year" <> 2003 OR "School_id" >= 4 AND "Budgeted" = 113531 AND "Invested" <> 5840 AND "total_budget_percent_invested" <= 2.0


Question: Which driver IDs are both less than or equal to 3 and also less than 10, considering driver IDs from the driver and school bus tables?

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 driver IDs that are less than or equal to 6, excluding those driver IDs that are less than or equal to 3 and are also associated with a school bus?

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


Question: What are the employee IDs of employees who are not George Chuter, are under 32 years old, and not employee ID 5, and also started working sometime other than 2009 and are not assigned to shop ID 6 or have an employee ID of 3 or greater?

SELECT Employee_ID FROM employee WHERE Name <> "George Chuter" AND "Age" < 32 AND "Employee_ID" != 5 INTERSECT SELECT Employee_ID FROM hiring WHERE Start_from != "2009" AND "Shop_ID" != 6 OR "Employee_ID" >= 3


Question: What are the property IDs from the 'Other_Property_Features' table where the property ID is 4, combined with the property IDs from the 'Properties' table where the sale date was November 7, 1997, or the shp_feature_3 is not "None", and the room count is not 5, and the hse_feature_1 is not "None", or the hse_feature_3 is not "None", or the agreed selling price is 0.0 and the property address is "60845 Else Highway Apt. 826 South Dougfort, CO 43200-4258" and the oth_feature_1 is not "None", or the oth_feature_2 is not "None" and the shp_feature_1 is not "None", or the buyer offered price is not 2449185.2, or the property ID is greater than 3?

SELECT property_id FROM Other_Property_Features WHERE "property_id" = 4 UNION ALL SELECT property_id FROM Properties WHERE date_sold = "1997-11-07 20:22:05" OR shp_feature_3 != "None" AND "room_count" != 5 AND hse_feature_1 <> "None" OR hse_feature_3 != "None" OR "agreed_selling_price" = 0.0 AND property_address = "60845 Else Highway Apt. 826 South Dougfort, CO 43200-4258" AND oth_feature_1 != "None" OR oth_feature_2 != "None" AND shp_feature_1 <> "None" OR "buyer_offered_price" != 2449185.2 OR "property_id" > 3


Question: Which driver IDs are either 8 or not 7, considering driver IDs from both the driver and school bus tables?

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


Question: What are the IDs of airports that are not EHAM, combined with the IDs of flights where the velocity is 240 or the flight number is not M2-F1 #13 and the altitude is at least 3650 and the airport ID is 2?

SELECT id FROM airport WHERE ICAO <> "EHAM" UNION SELECT id FROM flight WHERE "Velocity" = 240.0 OR Vehicle_Flight_number <> "M2-F1 #13" AND "Altitude" >= 3650.0 AND "airport_id" = 2


Question: Which driver IDs are greater than 3 and also appear in the school bus table, excluding driver ID 7?

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


Question: What are the driver IDs that are both equal to 9 and less than 10, considering driver and school bus information?

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


Question: Which driver IDs are either less than or equal to 3 from the driver table, or greater than or 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: What are the aircraft IDs that are not equal to 5, but are not present in the airport aircraft table with IDs greater than 5?

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


Question: How many employees have an ID greater than 3 or are in the ED role, and how many roles are MG?

SELECT COUNT(role_code) FROM Employees WHERE "employee_id" > 3 OR role_code = "ED" UNION SELECT COUNT(role_code) FROM Roles WHERE role_code = "MG"


Question: What are the driver IDs that are less than 10, and also the driver IDs that are 4 or less, considering both drivers and school buses?

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


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


Question: What is the count of students and clubs, and the average position, for members where the club ID is at least 1 and the student ID is no more than 1010, combined with the count of students and clubs, and the average position, for members where the club ID is no more than 2 and the position is CTO?

SELECT COUNT(StuID), AVG(Position), COUNT(ClubID) FROM Member_of_club WHERE "ClubID" >= 1 AND "StuID" <= 1010 UNION SELECT COUNT(StuID), AVG(Position), COUNT(ClubID) FROM Member_of_club WHERE "ClubID" <= 2 AND Position = "CTO"


Question: What are the aircraft IDs that are greater than or equal to 1 in the aircraft table, but not equal to 5 in the airport_aircraft table?

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


Question: What are the driver IDs, excluding driver ID 6, and also the driver IDs that are 3 or less, from the driver and school bus tables?

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


Question: Which driver IDs are associated with either a driver or a school bus, excluding driver ID 1 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 <> 1 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 7


Question: What are the driver IDs, excluding driver ID 11, from the driver table and also the driver IDs, greater than or equal to 9, 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 >= 9


Question: Which driver IDs are less than 5, and also driver ID 9, considering both drivers and school buses?

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


Question: What is the maximum coach name and the sum of coach IDs for female coaches who are not rank 2, combined with the maximum coach name and the sum of coach IDs for coaches named Smith Brown, or those with a club ID less than or equal to 1, or those who are not male, or those with a rank greater than 4?

SELECT MAX(Coach_name), Gender, SUM(Coach_ID) FROM coach WHERE Gender <> "M" AND "Rank" != 2 UNION ALL SELECT MAX(Coach_name), Gender, SUM(Coach_ID) FROM coach WHERE "Coach_ID" != 1 AND Coach_name = "Smith Brown" AND "Club_ID" <= 1 OR Gender <> "M" OR "Rank" > 4


Question: Which driver IDs are greater than 10 but not present in the school bus table, excluding driver ID 4?

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 IDs of drivers, excluding driver ID 3, who are either drivers or assigned to a school bus, but not driver ID 4?

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


Question: What is the highest customer ID from payments where the payment amount is at least 6970.98, the payment method isn't Credit Card, and the payment time isn't 2018-02-15 16:38:49, combined with the highest customer ID from lessons where the lesson time isn't 5 and the lesson ID is less than 15?

SELECT MAX(customer_id) FROM Customer_Payments WHERE "amount_payment" >= 6970.98 AND payment_method_code != "Credit Card" AND datetime_payment <> "2018-02-15 16:38:49" UNION SELECT MAX(customer_id) FROM Lessons WHERE lesson_time != "5" AND "lesson_id" < 15


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, considering both the 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 driver IDs are either 1 or not 7, considering driver and school bus information?

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 first names of customers with IDs greater than 8, excluding those whose first names appear in the staff records for employees born on November 16, 2000, and who did not leave the staff on March 9, 2018?

SELECT first_name FROM Customers WHERE "customer_id" > 8 EXCEPT SELECT first_name FROM Staff WHERE date_of_birth = "2000-11-16 06:55:12" AND date_left_staff <> "2018-03-09 05:08:35"


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

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


Question: Which driver IDs are greater than 6, excluding driver ID 9?

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


Question: What are the student IDs of students who have allergies other than cats, combined with the student IDs of students who are not male, or whose first name is Paul, or whose major is greater than 600, or whose city code is BOS and advisor is greater than or equal to 9172 and age is not 20, or whose last name is Schwartz?

SELECT StuID FROM Has_Allergy WHERE Allergy <> "Cat" UNION ALL SELECT StuID FROM Student WHERE Sex != "M" OR "StuID" != 1007 AND Fname = "Paul" OR "Major" > 600 OR city_code = "BOS" AND "Advisor" >= 9172 AND "Age" <> 20 OR LName = "Schwartz"


Question: Which driver IDs are less than 6 but not greater than or equal to 10, considering only the driver IDs present in the driver table and excluding those in the school bus table?

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


Question: What are the aircraft IDs that are either 4 or greater, or less than 2, considering both the aircraft and airport_aircraft tables?

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 that are present in both the driver table (excluding driver ID 4) and the school bus table (where the driver ID is greater than 4)?

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


Question: Which driver IDs, excluding driver 12, are present in both the driver and school bus records, and also excluding driver 10?

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


Question: What are the driver IDs that are less than 3, and also the driver IDs that are less than or equal to 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 driver IDs, excluding driver 11, from the driver table and the driver IDs, excluding driver 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: Which parties participated in election ID 8, or where the first elected year wasn't 1994, or the district wasn't 2, or the party wasn't 1 and the delegate was Guzzone, Guy Guy Guzzone, excluding those from the Economic Matters committee and counties represented as 12.2 12B? Also, which parties are "Independence", or where the comptroller isn't Alan Hevesi, or where the US Senator isn't Charles Schumer and the Governor is Peter Vallone and the Lieutenant Governor is Sandra Frankel, or where the Attorney General isn't Eliot Spitzer?

SELECT Party FROM election WHERE Committee != "Economic Matters" AND Counties_Represented != "12.2 12B" AND "Election_ID" = 8 OR "First_Elected" <> 1994.0 OR "District" <> 2 OR "Party" != 1 AND Delegate = "Guzzone, Guy Guy Guzzone" UNION ALL SELECT Party FROM party WHERE Party = "Independence" OR Comptroller != "Alan Hevesi" OR US_Senate != "Charles Schumer" AND Governor = "Peter Vallone" AND Lieutenant_Governor = "Sandra Frankel" AND "Party_ID" = 4 OR Attorney_General <> "Eliot Spitzer"


Question: Give me the vehicle IDs and details for all vehicles that are cars or have a vehicle ID other than 1, excluding those that are trucks.

SELECT vehicle_id, vehicle_details FROM Vehicles WHERE vehicle_details = "Car" OR "vehicle_id" != 1 EXCEPT SELECT vehicle_id, vehicle_details FROM Vehicles WHERE vehicle_details = "Truck"


Question: What are the driver IDs greater than 4, and also the driver ID 3, from the driver and school bus tables?

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


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


Question: What are the driver IDs that are both less than or equal to 11 and also not equal to 3, considering only those driver IDs present in both the driver and school bus tables?

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


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

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


Question: What are the average values of the template type code and description for template types that are not "Advertisement" and have the code "CV", combined with the average values of the template type code and description for template types that are not "Presentation"?

SELECT AVG(Template_Type_Code), AVG(Template_Type_Description) FROM Ref_Template_Types WHERE Template_Type_Description <> "Advertisement" AND Template_Type_Code = "CV" UNION ALL SELECT AVG(Template_Type_Code), AVG(Template_Type_Description) FROM Ref_Template_Types WHERE Template_Type_Description != "Presentation"


Question: What are the IDs of all aircraft, from both the aircraft and airport_aircraft tables, excluding aircraft with ID 2?

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


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

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


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

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


Question: What are the driver IDs, excluding driver ID 8, that are also driver IDs from school buses with IDs of 7 or higher?

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


Question: What are the driver IDs that are not 1 and are in the driver table, but not in the school bus table with IDs less than or equal to 7?

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


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


Question: What are the birth dates, maximum nationalities, average heights, and names of people who were born on August 8, 1986, are not named Roman Bragin, are not from Russia, and are at least 182cm tall, combined with the birth dates, maximum nationalities, average heights, and names of people with a People_ID greater than 5?

Birth_Date MAX(Nationality) AVG(Height) Name

SELECT Birth_Date, MAX(Nationality), AVG(Height), Name FROM people WHERE Name <> "Roman Bragin" AND Nationality <> "Russia" AND Birth_Date = "August 8, 1986" AND "Height" >= 182.0 UNION ALL SELECT Birth_Date, MAX(Nationality), AVG(Height), Name FROM people WHERE "People_ID" > 5


Question: What are the distances from the aircraft that are not Boeing 777-300 or have a distance greater than 2605, combined with the distances from flights that are not flight number 33 or have a destination other than Los Angeles, or a departure date other than 04/12/2005 07:03 and a price greater than 235.98, or an arrival date of 04/12/2005 07:05, or an aid other than 5?

SELECT distance FROM aircraft WHERE name != "Boeing 777-300" OR "distance" > 2605 UNION SELECT distance FROM flight WHERE "flno" != 33 OR destination != "Los Angeles" AND departure_date != "04/12/2005 07:03" AND "price" > 235.98 OR arrival_date = "04/12/2005 07:05" OR "aid" != 5


Question: What is the average of 'Other_Details' and the minimum 'Document_ID' for documents that aren't described as "h", have other details that aren't "None", and don't have a Document ID of 801801, excluding the average of 'Other_Details' and the minimum 'Document_ID' from paragraphs where the Document ID is 80 or greater?

SELECT AVG(Other_Details), MIN(Document_ID) FROM Documents WHERE Document_Description != "h" AND Other_Details != "None" AND "Document_ID" != 801801 EXCEPT SELECT AVG(Other_Details), MIN(Document_ID) FROM Paragraphs WHERE "Document_ID" >= 80


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

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


Question: What is the average age of employees from Wasps or named Lee Mears or who are 43 years old and have an employee ID of 8 or greater, excluding the average age of employees from Bristol or who are not 23 years old or not named George Chuter and whose employee ID is not 2?

SELECT AVG(Age) FROM employee WHERE City = "Wasps" OR Name = "Lee Mears" OR "Age" = 43 AND "Employee_ID" >= 8 EXCEPT SELECT AVG(Age) FROM employee WHERE City = "Bristol" OR "Age" <> 23 OR Name != "George Chuter" AND "Employee_ID" != 2


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

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


Question: Which driver IDs are either 8 or less than or equal to 9, 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 <= 9


Question: What are the largest document IDs from the drafts where the ID isn't 7 or the draft details are "r", combined with the largest document IDs from mailed documents where the mailing date isn't "1973-02-21 10:17:01" and the ID is less than 4?

SELECT MAX(document_id) FROM Document_Drafts WHERE "document_id" != 7 OR draft_details = "r" UNION SELECT MAX(document_id) FROM Documents_Mailed WHERE mailing_date != "1973-02-21 10:17:01" AND "document_id" < 4


Question: What are the market values in billions for companies that meet the following criteria: their sales are 147.3 billion and assets are not 1313.9 billion, or their headquarters is not in Netherlands, or their profits are less than 10.3 billion and market value is greater than 180.0 billion and industry is not oil and gas and name is not PetroChina, or their company ID is not 18.0; but exclude those companies with profits less than or equal to 31.7 billion?

SELECT Market_Value_in_Billion FROM company WHERE "Sales_in_Billion" = 147.3 AND "Assets_in_Billion" <> 1313.9 OR Headquarters != "Netherlands" OR "Profits_in_Billion" < 10.3 AND "Market_Value_in_Billion" > 180.0 AND Industry != "Oil and gas" AND Name <> "PetroChina" OR "Company_ID" != 18.0 EXCEPT SELECT Market_Value_in_Billion FROM company WHERE "Profits_in_Billion" <= 31.7


Question: Which driver IDs are both equal to 9 and greater than 3, considering only drivers and school buses?

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 greater than or equal to 4, excluding those driver IDs that are exactly 4, based on the driver and school bus information?

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


Question: What are the model, model ID, and maker for models that are "triumph" or have a maker less than or equal to 13 or a model ID greater than or equal to 27, but not including those that are "datsun" or have a maker greater than or equal to 6 or a model ID not equal to 19?

SELECT Model, ModelId, Maker FROM model_list WHERE Model = "triumph" OR "Maker" <= 13 OR "ModelId" >= 27 EXCEPT SELECT Model, ModelId, Maker FROM model_list WHERE Model = "datsun" OR "Maker" >= 6 OR "ModelId" <> 19


Question: What are the document type codes from the 'Documents' table that are not "CD", or have other details not equal to "w", or have a receipt number not equal to "79", or have a shipping agent code of "AL", or have a document status code not equal to "working" and a receipt date not equal to "1973-11-05 21:48:53", along with the document type codes from the 'Ref_Document_Types' table where the description is "b"?

SELECT document_type_code FROM Documents WHERE document_type_code <> "CD" OR other_details != "w" OR receipt_number <> "79" OR shipping_agent_code = "AL" OR document_status_code != "working" AND receipt_date <> "1973-11-05 21:48:53" UNION SELECT document_type_code FROM Ref_Document_Types WHERE document_type_description = "b"


Question: Which driver IDs are not equal to 12 but are not present in the school bus table where the driver ID is greater than 3?

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


Question: Which driver IDs are greater than or equal to 7 but are not present in the school bus table with driver IDs less 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 aircraft IDs that are both less than or equal to 3 and also less than 3, considering only the aircraft IDs 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: What are the driver IDs that are not 5, but are not also driver IDs that are 3 or less, considering drivers and school buses?

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


Question: What are the driver IDs, excluding driver ID 2, and also 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 book IDs of books written by Garth Ennis, combined with the book IDs from all publications except publication ID 7?

SELECT Book_ID FROM book WHERE Writer = "Garth Ennis" UNION SELECT Book_ID FROM publication WHERE "Publication_ID" != 7


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

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


Question: What are the driver IDs less than 11, excluding those driver IDs that are also present in the school bus table and are less than or equal to 4?

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


Question: What are the aircraft IDs that are either less than or equal to 1, or greater 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 <= 1 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID >= 2


Question: What are the driver IDs that appear in both the driver and school bus tables, where the driver ID is no more than 10 in the driver table and no more than 4 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 <= 4


Question: What are the IDs of coaches who are not named Jameson Tomas, excluding those whose IDs are also in the player_coach table with a starting year after 2012, coach ID less than 1, and player ID equal to 1?

SELECT Coach_ID FROM coach WHERE Coach_name <> "Jameson Tomas" EXCEPT SELECT Coach_ID FROM player_coach WHERE "Starting_year" > 2012 AND "Coach_ID" < 1 AND "Player_ID" = 1


Question: What are the document status codes that are not "mailed", but are not "overdue"?

SELECT document_status_code FROM Ref_Document_Status WHERE document_status_description <> "mailed" EXCEPT SELECT document_status_code FROM Ref_Document_Status WHERE document_status_code <> "overdue"


Question: What is the average company ID for companies where sales are at most 470.2 billion, or profits are at most 20.5 billion, or market value is not 294.7 billion, or the company name is not HSBC, excluding the average company ID from the employment table where the company ID is greater than 13 and the people ID is greater than 1?

SELECT AVG(Company_ID) FROM company WHERE "Sales_in_Billion" <= 470.2 AND "Company_ID" > 11.0 OR "Profits_in_Billion" <= 20.5 OR "Market_Value_in_Billion" != 294.7 OR Name != "HSBC" EXCEPT SELECT AVG(Company_ID) FROM employment WHERE "Company_ID" > 13 AND "People_ID" > 1


Question: Which driver IDs are greater than 11 but not present in the school bus table, excluding driver ID 9?

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


Question: What are the aircraft IDs, excluding ID 5, from the aircraft table, and also the aircraft IDs, excluding ID 3, from the airport_aircraft table?

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


Question: What are the driver IDs that appear in both the driver and school bus tables, where the driver ID is less than or equal to 3 in the driver table and less 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: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 6 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 <> 6 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 3


Question: What are the template type codes that are not "Presentation", combined with the template type codes from templates where the version number is 5 or greater, or template details are not empty, or the effective to date is not a specific date, or the template type code is "PP", or the effective from date is not a specific date?

SELECT Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Description != "Presentation" UNION SELECT Template_Type_Code FROM Templates WHERE "Version_Number" >= 5 OR Template_Details != "" AND Date_Effective_To != "1974-09-14 06:34:39" OR Template_Type_Code = "PP" OR Date_Effective_From != "2005-11-12 07:09:48"


Question: What are the aircraft IDs where the total disk area is not "8,495 ft² (789 m²)" or the maximum disk loading is not "2.6 lb/ft² (14 kg/m²)" or the maximum gross weight is "123,500 lb (56,000 kg)", excluding any aircraft IDs found in the airport_aircraft table with an Airport ID greater than or equal to 9 or an Aircraft ID greater than or equal to 1?

SELECT Aircraft_ID FROM aircraft WHERE Total_disk_area != "8,495 ft² (789 m²)" OR Max_disk_Loading != "2.6 lb/ft² (14 kg/m²)" OR Max_Gross_Weight = "123,500 lb (56,000 kg)" EXCEPT SELECT Aircraft_ID FROM airport_aircraft WHERE "Airport_ID" >= 9 OR "Aircraft_ID" >= 1


Question: What are the driver IDs, excluding driver ID 8, and also the driver IDs greater than 3, 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 > 3


Question: What is the contestant number of Jessie Alloway, excluding any contestant numbers that have votes from NY on March 9, 2018 at 7:03:36 PM, or where the contestant number is less than 3, or where the vote ID is 1?

SELECT contestant_number FROM CONTESTANTS WHERE contestant_name = "Jessie Alloway" EXCEPT SELECT contestant_number FROM VOTES WHERE state = "NY" AND created = "2018-03-09 19:03:36" OR "contestant_number" < 3 OR "vote_id" = 1


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

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


Question: Which driver IDs, excluding driver 11, are present in both the driver and school bus records, where the school bus driver IDs are 7 or less?

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


Question: Which driver IDs are greater than 11 but not present in the school bus table, excluding driver ID 4?

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


Question: What are the driver IDs that are greater than or equal to 8 and also not equal to 10, considering only those driver IDs present in both the driver and school bus tables?

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


Question: What is the paragraph text, average paragraph ID, and document ID for paragraphs where the text is "Ireland", or the document ID is greater than or equal to 2394, or the paragraph ID is not 9, combined with the paragraph text, average paragraph ID, and document ID for the paragraph with paragraph ID 946335436?

SELECT Paragraph_Text, AVG(Paragraph_ID), Document_ID FROM Paragraphs WHERE Paragraph_Text = "Ireland" OR "Document_ID" >= 2394 OR "Paragraph_ID" <> 9 UNION ALL SELECT Paragraph_Text, AVG(Paragraph_ID), Document_ID FROM Paragraphs WHERE "Paragraph_ID" = 946335436


Question: What are the driver IDs that are less than or equal to 12, excluding those driver IDs greater than 10 that are also in the school bus table?

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


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

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


Question: What are all the draft numbers, either where the copy number is not 10, or where the draft number is greater than 20 or the copy number is not 10 and the employee ID is 2?

SELECT draft_number FROM Circulation_History WHERE "copy_number" != 10 UNION SELECT draft_number FROM Circulation_History WHERE "draft_number" > 20 OR "copy_number" != 10 AND "employee_id" = 2


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


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

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


Question: What are the driver IDs greater than 6, and also the driver IDs from school buses that are not 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 driver IDs that are both less than or equal to 4 and also not equal to 7, considering only driver IDs present in both the driver and school bus tables?

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 airports in Iceland, excluding those with IATA code AMS and the airport named Schiphol Airport, where the ID is 1? Then, exclude any airport IDs that are not AMS and have an ID greater than or equal to 8, but only if the ID is also greater than or equal to 9.

SELECT id FROM airport WHERE Country = "Iceland" AND IATA != "AMS" AND name <> "Schiphol Airport" GROUP BY id HAVING id = 1 EXCEPT SELECT id FROM airport WHERE IATA <> "AMS" AND "id" >= 8 GROUP BY id HAVING id >= 9


Question: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 9, but only considering driver IDs less than 4?

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


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

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


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

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


Question: What are the feature IDs and the sum of property feature descriptions where the description is "modi" or the property ID is less than or equal to 3, excluding those feature IDs and sums where the feature ID is not 4 and the description is not "ad"?

SELECT feature_id, SUM(property_feature_description) FROM Other_Property_Features WHERE property_feature_description = "modi" OR "property_id" <= 3 EXCEPT SELECT feature_id, SUM(property_feature_description) FROM Other_Property_Features WHERE "feature_id" <> 4 AND property_feature_description <> "ad"


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


Question: For each company, how many headquarters, industries, and sales records are there, and what is the sum of their market value? Show me this information for companies where the number of sales records is at most 1 or the total market value is at most 407.4 billion, or where the number of sales records is less than 1, the number of headquarters is greater than 1, or the total market value is at most 227.6 billion.

SELECT COUNT(Headquarters), Company_ID, COUNT(Industry), SUM(Market_Value_in_Billion), COUNT(Sales_in_Billion) FROM company GROUP BY Company_ID HAVING COUNT(Sales_in_Billion) <= 1 OR SUM(Market_Value_in_Billion) <= 407.4 UNION SELECT COUNT(Headquarters), Company_ID, COUNT(Industry), SUM(Market_Value_in_Billion), COUNT(Sales_in_Billion) FROM company GROUP BY Company_ID HAVING COUNT(Sales_in_Billion) < 1 OR COUNT(Headquarters) > 1 OR SUM(Market_Value_in_Billion) <= 227.6


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

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


Question: Which driver IDs, excluding ID 10, are associated with drivers, and which driver IDs, less than 3, are associated with school buses?

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


Question: What are the driver IDs greater than 7 who are in the driver table but not in the school bus table, considering only driver IDs greater than 4 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 > 4


Question: What is the highest customer ID from the Customer_Payments table where the customer ID is greater than 12 and the payment method is not "Credit Card", combined with the highest customer ID from the Customers table where the amount outstanding is not 9443.0 and the customer ID is not 3, considering various other conditions related to customer status, first name, date of becoming a customer, cell phone number, email address, customer address ID, last name, phone number, and date of birth?

SELECT MAX(customer_id) FROM Customer_Payments WHERE "customer_id" > 12 AND payment_method_code <> "Credit Card" UNION ALL SELECT MAX(customer_id) FROM Customers WHERE "amount_outstanding" <> 9443.0 AND "customer_id" <> 3 AND customer_status_code <> "Bad Customer" OR first_name <> "Carole" AND date_became_customer = "2016-05-13 07:38:23" OR cell_mobile_phone_number = "1-387-258-1016x96963" AND email_address <> "mariela28@example.org" OR "customer_address_id" >= 1 AND last_name != "Kohler" OR phone_number != "(729)396-4354x3576" OR date_of_birth = "1993-03-08 08:48:42"


Question: What are the driver IDs, excluding driver ID 1, and also driver ID 10?

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: Which driver IDs are less than 4 but not greater than 3, considering only the driver and school bus information?

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


Question: What are the aircraft IDs that are not equal to 5, but are not present in the airport_aircraft table with IDs greater than or equal to 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: How many pets have a PetID other than 2001, and how many pets weigh at least 12.0?

SELECT COUNT(PetID) FROM Has_Pet WHERE "PetID" <> 2001 UNION ALL SELECT COUNT(PetID) FROM Pets WHERE "weight" >= 12.0


Question: Which aircraft have an ID of 3 and are listed 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: What are the aircraft IDs that are less than 5 in the aircraft table, combined with the aircraft IDs that are less than or equal to 2 in the airport_aircraft table?

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


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


Question: What are the driver IDs that are both less than or equal to 4 and also appear in the school bus table with IDs less than 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 aircraft IDs that are greater than 1 and also appear in the airport aircraft table, excluding those with an ID of 3?

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


Question: What are the driver IDs, excluding driver ID 3, and also any driver IDs greater than 3, that are found in either the driver or school bus records?

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


Question: What are the album IDs that are not 249 and also appear in the employee IDs where the employee is from Canada or has a first name other than Laura and a birth date not equal to July 1, 1973, and a state not equal to AB and a hire date of January 2, 2004, or has an email that is not jane@chinookcorp.com and does not report to employee ID 2 or has a postal code that is not T2P 5M5 or has a phone number that is not +1 (403) 467-3351 and a fax number that is not +1 (780) 428-3457 and an employee ID less than or equal to 1 and a title that is not General Manager?

SELECT id FROM albums WHERE "id" != 249 INTERSECT SELECT id FROM employees WHERE country = "Canada" OR first_name <> "Laura" AND birth_date != "1973-07-01 00:00:00" AND state <> "AB" AND hire_date = "2004-01-02 00:00:00" OR email <> "jane@chinookcorp.com" AND "reports_to" != 2.0 OR postal_code != "T2P 5M5" OR phone <> "+1 (403) 467-3351" AND fax <> "+1 (780) 428-3457" AND "id" <= 1 AND title != "General Manager"


Question: What are the driver IDs that are 4 or greater, considering both drivers and school buses?

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


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

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


Question: Which driver IDs are less than or equal to 3, excluding driver ID 7?

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


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

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


Question: What are the average school names, locations, minimum mascots, counties, minimum enrollments, counts of football classes, and maximum IHSAA classes for schools that either have an enrollment of at least 605 and are not school ID "2", or are not located in Bremen?

SELECT AVG(School_name), Location, MIN(Mascot), County, MIN(Enrollment), COUNT(IHSAA_Football_Class), MAX(IHSAA_Class) FROM School WHERE School_id <> "2" AND "Enrollment" >= 605 UNION SELECT AVG(School_name), Location, MIN(Mascot), County, MIN(Enrollment), COUNT(IHSAA_Football_Class), MAX(IHSAA_Class) FROM School WHERE Location <> "Bremen"


Question: What are the driver IDs greater than 9 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 > 9 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID > 10


Question: What are the user IDs and the maximum names for users in the useracct table, excluding those named Mark or Rosie, and also excluding user ID 6?

SELECT u_id, MAX(name) FROM useracct WHERE name != "Mark" AND "u_id" != 6 UNION ALL SELECT u_id, MAX(name) FROM useracct WHERE name != "Rosie"


Question: What are the effective dates, template details, and template type codes for templates with a version number greater than 9 and a date effective from not equal to April 5, 2012, or with template details not empty, or with a date effective to not equal to May 2, 1992? Also, what are the effective dates, template details, and template type codes for templates with a template ID greater than 22 and a template type code not equal to PP?

SELECT Date_Effective_To, Date_Effective_From, Template_Details, Template_Type_Code FROM Templates WHERE "Version_Number" > 9 AND Date_Effective_From != "2012-04-05 07:11:42" OR Template_Details != "" OR Date_Effective_To <> "1992-05-02 20:06:11" UNION SELECT Date_Effective_To, Date_Effective_From, Template_Details, Template_Type_Code FROM Templates WHERE "Template_ID" > 22 AND Template_Type_Code != "PP"


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

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


Question: What are the item IDs, ranks, and ratings from the reviews where the rank is not 5 or the item ID is not 7, and also where the rank is not 1 and the item ID is greater than 7, or the author ID is greater than 2, or the rating is less than or equal to 10?

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


Question: What are the aircraft IDs that are less than 4 and present in both the aircraft and airport aircraft tables, where the aircraft ID is also less than 3 in the airport aircraft table?

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


Question: What are the IDs of documents that are not "Hard Drive" type, don't have "x" as other details, and aren't in "working" status, along with the IDs of draft copies where the copy number is 10 or less, or the document ID is not 10 and the draft number is not 1?

SELECT document_id FROM Documents WHERE document_type_code <> "Hard Drive" AND other_details <> "x" AND document_status_code != "working" UNION SELECT document_id FROM Draft_Copies WHERE "copy_number" <= 10 OR "document_id" != 10 AND "draft_number" != 1


Question: Which driver IDs, excluding driver ID 1, are associated with drivers, and which driver IDs, excluding driver ID 3, are associated with 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 != 3


Question: What are the aircraft IDs that are less than or equal to 1, excluding those aircraft IDs that are greater than or equal to 2?

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


Question: What are the aircraft IDs that are less than 2 in the aircraft table, combined with the aircraft IDs that are greater than 3 in the airport_aircraft table?

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


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


Question: What are the driver IDs that appear in both the driver and school bus tables, where the driver ID is no more than 5 in the driver table and no more than 4 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 <= 4


Question: What are the Model IDs and Makers of models where the Model ID is less than 4, the model is "mazda", or the Maker is greater than 4, and also where the Maker is not 3?

SELECT ModelId, Maker FROM model_list WHERE "ModelId" < 4 OR Model = "mazda" OR "Maker" > 4 INTERSECT SELECT ModelId, Maker FROM model_list WHERE "Maker" != 3


Question: What are the document type codes for documents with an ID of 17 or higher, excluding those shipped by US agents, with a receipt number other than 8 and other details not equal to "h", and also the document type codes from document types that are not described as "f" or have a code other than "Hard Drive"?

SELECT document_type_code FROM Documents WHERE "document_id" >= 17 AND shipping_agent_code != "US" AND receipt_number <> "8" AND other_details <> "h" UNION SELECT document_type_code FROM Ref_Document_Types WHERE document_type_description != "f" OR document_type_code != "Hard Drive"


Question: What are the names, IDs, and distances of aircraft that are not an Airbus A340-300 and also not a Boeing 737-800?

SELECT name, aid, distance FROM aircraft WHERE name != "Airbus A340-300" INTERSECT SELECT name, aid, distance FROM aircraft WHERE name != "Boeing 737-800"


Question: What are the driver IDs that are either greater than or equal to 2 in the driver table or not equal to 9 in the school bus table?

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


Question: What are the aircraft IDs that are either less than or equal to 1, or 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: What are the aircraft IDs, excluding aircraft ID 4, and also including aircraft IDs less than or 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 that are equal to 5, excluding those driver IDs that are not 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: Which driver IDs are equal to 8 but not greater than 9, considering only driver IDs from the driver and school bus tables?

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 either aircraft ID 5 or airport aircraft ID 2?

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: What is the average name from the employee table where the age is greater than 29, and what is the average name from the shop table where the number of products is at least 10000 or the shop ID is 2?

SELECT AVG(Name) FROM employee WHERE "Age" > 29 INTERSECT SELECT AVG(Name) FROM shop WHERE "Number_products" >= 10000 OR "Shop_ID" = 2


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

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


Question: What are the document IDs that meet any of these conditions: the receipt date isn't "2005-09-30 00:10:02", the document status isn't "working", the receipt number isn't "34", the document ID is less than 10, or the shipping agent code isn't "FE", but are not in the list of document IDs where the mailed to address ID isn't 0 or the document ID isn't 12?

SELECT document_id FROM Documents WHERE receipt_date <> "2005-09-30 00:10:02" AND document_status_code <> "working" OR receipt_number <> "34" OR "document_id" < 10 OR shipping_agent_code <> "FE" EXCEPT SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" <> 0 OR "document_id" <> 12


Question: What are the names of aircraft that are not Piper Archer III or have a distance not equal to 7120 and aid not equal to 7, combined with the names of employees whose employee ID is less than 248965255 or are not named Haywood Kelly?

SELECT name FROM aircraft WHERE name != "Piper Archer III" OR "distance" != 7120 AND "aid" <> 7 UNION ALL SELECT name FROM employee WHERE "eid" < 248965255 OR name != "Haywood Kelly"


Question: How many template types are described as "Paper", and how many templates have an ID less than or equal to 23 and a version number less than or equal to 0, or have an effective end date of November 4, 1979?

SELECT COUNT(Template_Type_Code) FROM Ref_Template_Types WHERE Template_Type_Description = "Paper" UNION ALL SELECT COUNT(Template_Type_Code) FROM Templates WHERE "Template_ID" <= 23 AND "Version_Number" <= 0 OR Date_Effective_To = "1979-11-04 08:58:39"


Question: What are the employee IDs of employees who don't live in Wasps, combined with the employee IDs of employees whose awards weren't in 2011 or had a bonus less than or equal to 2900 and an employee ID of 1?

SELECT Employee_ID FROM employee WHERE City <> "Wasps" UNION SELECT Employee_ID FROM evaluation WHERE Year_awarded != "2011" OR "Bonus" <= 2900.0 AND Employee_ID = "1"


Question: What are the aircraft IDs that are 3, but not 1, based on the aircraft and airport_aircraft tables?

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

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