Question: Can you give me a list of driver IDs that are greater than 9 and also not equal to 4, considering only the driver IDs that appear in both the driver and school_bus tables?

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


Question: What is the highest shipping agent code from the Documents table, excluding those with "j" in other details, combined with the highest shipping agent code from the Ref_Shipping_Agents table, considering only codes that are not "US" and either the name is "Fedex" or the description is "w"?

SELECT MAX(shipping_agent_code) FROM Documents WHERE other_details != "j" UNION SELECT MAX(shipping_agent_code) FROM Ref_Shipping_Agents WHERE shipping_agent_code != "US" AND shipping_agent_name = "Fedex" OR shipping_agent_description = "w"


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

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


Question: Can you give me the smallest address detail and the address ID for addresses where the address detail is not "IT" and the address ID is 1, combined with the smallest address detail and address ID for addresses where the address ID is not 2?

SELECT MIN(address_details), address_id FROM Addresses WHERE address_details != "IT" AND "address_id" = 1 UNION ALL SELECT MIN(address_details), address_id FROM Addresses WHERE "address_id" <> 2


Question: Which driver IDs, excluding driver ID 12, are also driver IDs for school buses, excluding driver ID 9?

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


Question: What is the average club ID for clubs that are not located in HHH and have the description "Play pen and paper games on campus," combined with the average club ID for members who are not presidents and have a student ID less than 1007?

SELECT AVG(ClubID) FROM Club WHERE ClubLocation != "HHH" AND ClubDesc = "Play pen and paper games on campus." UNION ALL SELECT AVG(ClubID) FROM Member_of_club WHERE Position != "President" AND "StuID" < 1007


Question: What are the average major and student ID for students where the advisor is less than 8722, the first name isn't Michael, and the age isn't 20, combined with the average major and student ID for students where the student ID is 1035, or the major isn't 600 and the last name isn't Thornton, or the advisor is less than 8741, or the first name isn't Paul, or the age is less than 19, or the sex isn't female?

SELECT AVG(Major), StuID FROM Student WHERE "Advisor" < 8722 AND Fname != "Michael" AND "Age" <> 20 UNION ALL SELECT AVG(Major), StuID FROM Student WHERE "StuID" = 1035 OR "Major" != 600 AND LName <> "Thornton" OR "Advisor" < 8741 OR Fname != "Paul" OR "Age" < 19 OR Sex <> "F"


Question: Could you give me a list of user IDs from the review table where the ID is greater than 2, along with a list of user IDs from the user account table where the ID is less than 5?

SELECT u_id FROM review WHERE "u_id" > 2 UNION ALL SELECT u_id FROM useracct WHERE "u_id" < 5


Question: Can you give me the head IDs of people who are either younger than 69 or not born in Delaware, excluding the head IDs of people in management who are not head ID 4 and are not temporary acting?

SELECT head_ID FROM head WHERE "age" < 69.0 OR born_state != "Delaware" EXCEPT SELECT head_ID FROM management WHERE "head_ID" <> 4 AND temporary_acting <> "Yes"


Question: What aircraft IDs are both greater than or equal to 3 and also not equal to 1 in the airport aircraft?

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


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

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


Question: What is the smallest customer ID from the customer payments where either the payment amount isn't 8180.26, or the customer ID is 13 or greater, or the payment date is February 27, 2018 at 8:08:53 PM, or the payment method isn't Direct Debit, combined with the smallest customer ID from the lessons where the lesson status isn't Completed and the lesson date isn't February 26, 2018 at 2:36:35 AM?

SELECT MIN(customer_id) FROM Customer_Payments WHERE "amount_payment" != 8180.26 OR "customer_id" >= 13 OR datetime_payment = "2018-02-27 20:08:53" OR payment_method_code != "Direct Debit" UNION ALL SELECT MIN(customer_id) FROM Lessons WHERE lesson_status_code != "Completed" AND lesson_date != "2018-02-26 02:36:35"


Question: Can you list all aircraft IDs that are greater than 3 from the aircraft table, and combine that with a list of all aircraft IDs that are not equal to 5 from the airport_aircraft table?

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


Question: Can you provide a list showing, for each effective date and template type, the number of effective-to dates and the smallest template ID, combining results from two groups: one where the version number is greater than 2, and another where the version number is not equal to 5, or the effective-from date is not "2008-08-01 13:57:26", and the effective-to date is not "1994-12-07 13:26:23", and the template details are not empty, or the template ID is not 25?

SELECT Date_Effective_From, Template_Type_Code, COUNT(Date_Effective_To), MIN(Template_ID) FROM Templates WHERE "Version_Number" > 2 UNION ALL SELECT Date_Effective_From, Template_Type_Code, COUNT(Date_Effective_To), MIN(Template_ID) FROM Templates WHERE "Version_Number" != 5 OR Date_Effective_From <> "2008-08-01 13:57:26" AND Date_Effective_To <> "1994-12-07 13:26:23" AND Template_Details <> "" OR "Template_ID" != 25


Question: What is the average party value from the election table, excluding records where the delegate is Frank S. Turner, the election ID is less than 1, the party is 1 and first elected before 2002, or the committee is not Environmental Matters (Vice-Chair), after removing the average party value from the party table where the party is not Democratic, the party ID is less than 1, and neither the Attorney General nor the Governor is Eliot Spitzer?

SELECT AVG(Party) FROM election WHERE Delegate <> "Turner, Frank S. Frank S. Turner" AND "Election_ID" < 1 OR "Party" = 1 AND "First_Elected" < 2002.0 OR Committee <> "Environmental Matters (Vice-Chair)" EXCEPT SELECT AVG(Party) FROM party WHERE Party != "Democratic" AND "Party_ID" < 1 AND Attorney_General <> "Eliot Spitzer" AND Governor <> "Eliot Spitzer"


Question: Can you give me a list of driver IDs from the driver table that are less than 4, combined with a list of driver IDs from the school_bus table that are 7 or greater?

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


Question: Could you give me a list of player IDs for players who either didn't have coach ID 2 or started after 2011, but excluding those who had coach ID 3?

SELECT Player_ID FROM player_coach WHERE "Coach_ID" <> 2 OR "Starting_year" > 2011 EXCEPT SELECT Player_ID FROM player_coach WHERE "Coach_ID" = 3


Question: Can you give me a list of driver IDs from the driver table that are 5 or greater, and combine that with a list of driver IDs from the school bus table that are greater than 9?

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


Question: Can you list all the driver IDs that are less than 9 from the driver table, and combine that with a list of all driver IDs that are less 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: Can you give me a list of driver IDs, including those from the driver table that are less than or equal to 11, and those from the school bus table that are not equal to 7?

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


Question: Could you give me a list of customer IDs from payments that weren't made by direct debit and were for 7440.34, or where the customer ID isn't 4 and the payment wasn't made on 2018-02-24 10:07:05, combined with a list of customer IDs from lessons that were held on 2018-03-03 15:10:16 at 5 o'clock, or where the staff ID isn't 11 and the lesson was cancelled and the customer ID is 6, or where the vehicle ID isn't 3?

SELECT customer_id FROM Customer_Payments WHERE payment_method_code <> "Direct Debit" AND "amount_payment" = 7440.34 OR "customer_id" != 4 AND datetime_payment <> "2018-02-24 10:07:05" UNION SELECT customer_id FROM Lessons WHERE lesson_date = "2018-03-03 15:10:16" AND lesson_time = "5" OR "staff_id" != 11 AND lesson_status_code = "Cancelled" AND "customer_id" = 6 OR "vehicle_id" != 3


Question: Can you give me a list of People IDs, including those from the 'people' table who are not person ID 1, or are Russian, or are not 207 cm tall, or were not born on August 8, 1986, combined with those from the 'poker_player' table who have earnings less than $104,871?

SELECT People_ID FROM people WHERE "People_ID" != 1 OR Nationality = "Russia" OR "Height" != 207.0 OR Birth_Date != "August 8, 1986" UNION SELECT People_ID FROM poker_player WHERE "Earnings" < 104871.0


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

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


Question: Can you list all the feature type codes, including those that aren't "Amenity, eg Pool.", and also those that aren't "Security" while also not being named "Securiyt, eg Burglar Alarm."?

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


Question: Can you give me the student IDs of members who either don't hold the CTO position or have a ClubID less than or equal to 1 and a StuID of 1008, excluding the student IDs of students who don't live in YYZ, are not female, don't have the last name Rugh, have an advisor ID less than or equal to 8772, and don't have the first name Sarah?

SELECT StuID FROM Member_of_club WHERE Position != "CTO" OR "ClubID" <= 1 AND "StuID" = 1008 EXCEPT SELECT StuID FROM Student WHERE city_code != "YYZ" AND Sex <> "F" AND LName != "Rugh" AND "Advisor" <= 8772 AND Fname <> "Sarah"


Question: Can you give me a list of driver IDs, including those with the ID 1 from the driver table, and those with IDs less than 9 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 < 9


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

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


Question: What are the highest document status code and the average document status description, first excluding entries where the code is "done" and the description is "mailed late", and then including only entries where the code is "working" or the description is not "currently working on"?

SELECT MAX(document_status_code), AVG(document_status_description) FROM Ref_Document_Status WHERE document_status_code != "done" AND document_status_description != "mailed late" UNION ALL SELECT MAX(document_status_code), AVG(document_status_description) FROM Ref_Document_Status WHERE document_status_code = "working" OR document_status_description != "currently working on"


Question: Which driver IDs are both not equal to 5 in the driver table and equal to 3 in the school_bus table?

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


Question: Which driver IDs are less than 8 and also equal to 7 in the school bus records?

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


Question: Can you list all the aircraft IDs, excluding aircraft ID 2, and also list all the aircraft IDs from the airport, excluding aircraft ID 5?

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


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

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


Question: Can you give me a list of shipping agent codes from the Documents table where the document ID is less than 25, but exclude any codes that are either "UP" or have a description of "g" in the Ref_Shipping_Agents table?

SELECT shipping_agent_code FROM Documents WHERE "document_id" < 25 EXCEPT SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_code = "UP" OR shipping_agent_description = "g"


Question: Can you give me a list of driver IDs, including driver ID 1 from the driver table and any driver IDs less than 9 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 < 9


Question: Can you give me a list of driver IDs that are both greater than or equal to 10 and are not equal to 7, considering only unique driver IDs from the driver and school bus tables?

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


Question: Can you give me a list of driver IDs that are less than 12 from the driver table, combined with a list of driver IDs that are not equal to 9 from the school bus table?

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


Question: Can you give me a list of driver IDs, combining those from the driver table excluding driver ID 7, with those from the school bus table that are greater than 10?

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: Which driver IDs, excluding 12, are also driver IDs less than 10 in the school bus list?

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

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


Question: Can you give me a list of driver IDs, including those from the driver table that are not 11, and also including driver ID 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: Can you give me a list of property IDs that either have a feature ID other than 3 or a property feature description that isn't "hic", combined with property IDs from properties where the vendor requested price is greater than 13.4715 and either apt_feature_2 is "odio", the date on market is "1978-05-15 10:53:37", or a complex set of conditions involving shp_feature_2, hse_feature_1, shp_feature_1, property_type_code, agreed_selling_price, other_property_details, fld_feature_1, hse_feature_3, room_count, hse_feature_2, oth_feature_1, fld_feature_2, oth_feature_3, and apt_feature_1?

SELECT property_id FROM Other_Property_Features WHERE "feature_id" <> 3 OR property_feature_description != "hic" UNION SELECT property_id FROM Properties WHERE "vendor_requested_price" > 13.4715 AND apt_feature_2 = "odio" OR date_on_market = "1978-05-15 10:53:37" OR shp_feature_2 = "None" AND hse_feature_1 != "None" AND shp_feature_1 = "None" AND property_type_code <> "Apartment" OR "agreed_selling_price" >= 3344706.5755 OR other_property_details != "None" AND fld_feature_1 <> "None" AND hse_feature_3 <> "None" AND "room_count" < 8 OR hse_feature_2 <> "None" OR oth_feature_1 <> "None" AND fld_feature_2 = "None" AND oth_feature_3 = "None" AND apt_feature_1 = "fuga"


Question: What aircraft have an ID of 4, but are not in the set of aircraft with IDs less than 5 that are associated with airports?

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


Question: What is the average party value from the election table, excluding elections with ID 3, minus the average party value from the party table, excluding parties with ID 7 that are not Democratic, where US Senator is not Hillary Rodham Clinton, or the year is 2002 or later, or the Comptroller is not Carl McCall, or the Lieutenant Governor is not Dennis Mehiel and the Governor is Eliot Spitzer?

SELECT AVG(Party) FROM election WHERE "Election_ID" != 3 EXCEPT SELECT AVG(Party) FROM party WHERE "Party_ID" <> 7 AND Party != "Democratic" AND US_Senate <> "Hillary Rodham Clinton" OR "Year" >= 2002.0 OR Comptroller <> "Carl McCall" OR Lieutenant_Governor <> "Dennis Mehiel" AND Governor = "Eliot Spitzer"


Question: Can you give me the IDs of clubs that either don't have the description "Refurbish computers; teach kids and adults about computer basics." or are located in AKW and have a ClubID of 2, but excluding any club IDs that are associated with members whose student ID is less than 1001 and who don't hold the position of CTO?

SELECT ClubID FROM Club WHERE ClubDesc != "Refurbish computers; teach kids and adults about computer basics." OR ClubLocation = "AKW" AND "ClubID" = 2 EXCEPT SELECT ClubID FROM Member_of_club WHERE "StuID" < 1001 AND Position <> "CTO"


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

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


Question: Can you give me a list of driver IDs, including those that are not equal to 1 from the driver table, and those that are equal to 9 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 = 9


Question: Can you give me a list of student IDs from the Has_Pet table where the PetID is less than or equal to 2001, combined with a list of student IDs from the Student table where either the first name is not Mark and the Advisor is less than or equal to 8772 and the last name is Jones, or the sex is not female and the city code is not BAL, or the major is not 50 and the student ID is less than or equal to 1020, or the age is less than 19?

SELECT StuID FROM Has_Pet WHERE "PetID" <= 2001 UNION ALL SELECT StuID FROM Student WHERE Fname <> "Mark" AND "Advisor" <= 8772 AND LName = "Jones" OR Sex != "F" AND city_code <> "BAL" OR "Major" <> 50 AND "StuID" <= 1020 OR "Age" < 19


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

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


Question: Can you give me a list of driver IDs, including those with ID 1 from the driver table and those with IDs less than 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: Can you give me a list of driver IDs from the driver table that are greater than or equal to 2, excluding any driver IDs that are equal to 10 in the school_bus table?

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


Question: Can you give me a list of driver IDs that are not 4 from the driver table, but only include those driver IDs that are less than 4 from 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 < 4


Question: Which driver IDs are greater than 4 and also not equal to 10, considering drivers from both the driver and school bus lists?

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


Question: Can you give me a list of driver IDs, where each ID is greater than 1, but excluding any driver IDs that are also in the school bus list, unless that ID is 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: Can you list the property feature descriptions that apply to properties with a feature ID of 3 or higher and are not associated with property ID 12, excluding any feature descriptions that apply to properties with a property ID of 6 or lower?

SELECT property_feature_description FROM Other_Property_Features WHERE "feature_id" >= 3 AND "property_id" != 12 EXCEPT SELECT property_feature_description FROM Other_Property_Features WHERE "property_id" <= 6


Question: Could you list the school IDs for all schools that are not private, not located in Cambridge, Massachusetts, not named Punahou School, and not offering 4th grade, combined with the school IDs from the school bus table where either the driver is full-time, the school ID is not 4, or the years of working is not 8?

SELECT School_ID FROM school WHERE Type <> "Private" AND Location <> "Cambridge, Massachusetts" AND School != "Punahou School" AND Grade <> "4th grade" UNION ALL SELECT School_ID FROM school_bus WHERE If_full_time = "T" OR "School_ID" != 4 OR "Years_Working" <> 8


Question: Can you give me a list of driver IDs that are less than 12, excluding those driver IDs that are also greater than or equal to 10 and associated with a school bus?

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


Question: Can you list the aircraft IDs, up to and including 4, that appear in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 2 from 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: Can you list all driver IDs that are less than 3, including those from the driver table and the school bus table, removing any duplicates?

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


Question: Which aircraft IDs are both less than or equal to 5 when considering only aircraft and less than 5 when considering only airport aircraft?

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


Question: Can you give me a list of driver IDs, including those from the driver table excluding driver ID 12, and those from the school bus table excluding driver ID 10?

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


Question: Can you give me a list of driver IDs, including those from the driver table where the ID is 9 or greater, and those from the school bus table where the ID is not 7?

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


Question: Can you list all aircraft IDs, excluding aircraft ID 5, and also list all aircraft IDs from the airport aircraft table that are 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: Can you give me a list of driver IDs from the driver table where each ID is less than or equal to 8, combined with a list of driver IDs from the school_bus table where each ID is greater than 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: Can you list the aircraft IDs, excluding aircraft ID 4, from the aircraft table, and combine that with a list of aircraft IDs, excluding aircraft ID 2, from the airport_aircraft table, removing any duplicates?

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


Question: Could you give me the document IDs from the drafts that either have draft details marked as "r" or are not document ID 13, but exclude any document IDs that were mailed to an address ID greater than 7, mailed on a date other than March 20, 2007 at 5:22:01 AM, and have a document ID less than or equal to 24?

SELECT document_id FROM Document_Drafts WHERE draft_details = "r" OR "document_id" != 13 EXCEPT SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" > 7 AND mailing_date <> "2007-03-20 05:22:01" AND "document_id" <= 24


Question: Can you give me a list of driver IDs that are less than 5 and also appear as driver IDs in the school bus table, excluding driver ID 10?

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


Question: What are the property type codes and their counts, excluding those where the property type description is not "House, Bungalow, etc.", from the property types that are either "Apartment, Flat, Condo, etc." or not "Other"?

SELECT property_type_code, COUNT(property_type_description) FROM Ref_Property_Types WHERE property_type_description = "Apartment, Flat, Condo, etc." OR property_type_code != "Other" EXCEPT SELECT property_type_code, COUNT(property_type_description) FROM Ref_Property_Types WHERE property_type_description <> "House, Bungalow, etc."


Question: Can you give me a list of driver IDs, including those that are exactly 1 from the driver list, and those that are 3 or greater from the school bus list?

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


Question: Could you give me the document IDs that are both in the circulation history for employees other than employee 8 with copy numbers less than or equal to 10, and also in the documents mailed on November 3, 1971 at 12:32:14 to address IDs less than or equal to 8, or are not document ID 2?

SELECT document_id FROM Circulation_History WHERE "employee_id" <> 8 AND "copy_number" <= 10 INTERSECT SELECT document_id FROM Documents_Mailed WHERE mailing_date = "1971-11-03 12:32:14" AND "mailed_to_address_id" <= 8 OR "document_id" != 2


Question: Can you give me a list of driver IDs where the ID is greater than 4 from the driver table, combined with a list of driver IDs that are exactly 3 from the school bus table?

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


Question: Can you give me a list of driver IDs that are not equal to 6, excluding any driver IDs from the school bus table that are less than 3?

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


Question: Can you give me a list of driver IDs, including those from the driver table that are 8 or higher, and those from the school bus table that are greater than 7?

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: Could you give me the copy numbers that are both less than or equal to 15 in the Circulation History, excluding those associated with employee ID 2, document IDs of 20 or greater, and draft numbers of 1 or less, and also less than or equal to 10 in the Draft Copies, excluding those associated with document ID 4?

SELECT copy_number FROM Circulation_History WHERE "copy_number" <= 15 AND "employee_id" != 2 AND "document_id" < 20 AND "draft_number" > 1 INTERSECT SELECT copy_number FROM Draft_Copies WHERE "copy_number" <= 10 AND "document_id" <> 4


Question: Can you give me a list of driver IDs, combining those from the driver table excluding ID 9 with those from the school bus table that are less than or equal to 10?

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


Question: Can you give me the IDs of drivers with IDs less than or equal to 7, excluding the IDs of school bus drivers that are not 10?

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


Question: Can you show me the Party, US Senate, and Governor information from the party table where the Party ID is 4, or the Attorney General isn't Jeanine Pirro, or the Party isn't Democratic, or the Comptroller is John Faso, or the Year is 2006 or later, combined with the Party, US Senate, and Governor information where the Year isn't 1998 and the Party isn't Democratic, or the Party ID is 1?

Democratic
Charles Schumer
Peter Vallone

Liberal
Charles Schumer
Betsy McCaughey Ross

Democratic
Hillary Rodham Clinton
Eliot Spitzer

Independence
Hillary Rodham Clinton
Eliot Spitzer

Working Families
Hillary Rodham Clinton
Eliot Spitzer

Democratic
Charles Schumer
Peter Vallone

Independence
Hillary Rodham Clinton
Eliot Spitzer

Working Families
Hillary Rodham Clinton
Eliot Spitzer

SELECT Party, US_Senate, Governor FROM party WHERE "Party_ID" = 4 OR Attorney_General != "Jeanine Pirro" OR Party != "Democratic" OR Comptroller = "John Faso" OR "Year" >= 2006.0 UNION ALL SELECT Party, US_Senate, Governor FROM party WHERE "Year" <> 1998.0 AND Party <> "Democratic" OR "Party_ID" = 1


Question: Can you show me the velocity, pilot, airport ID, and altitude from the flight table, combining two sets of results: first, flights where the airport ID is greater than 5 and the vehicle flight number is not "M2-F1 #13", or where the altitude is less than or equal to 3650, the ID is less than 10, the company ID is 2, and the pilot is Thompson, or where the velocity is greater than or equal to 240, or the date is not May 19, 1964; and second, flights where the vehicle flight number is not "M2-F1 #39", the ID is 7, the airport ID is not 4, the company ID is 7, the pilot is not Thompson, and the date is not March 1, 1963, or where the velocity is greater than 240?

SELECT Velocity, Pilot, airport_id, Altitude FROM flight WHERE "airport_id" > 5 AND Vehicle_Flight_number <> "M2-F1 #13" OR "Altitude" <= 3650.0 AND "id" < 10 AND "company_id" = 2 AND Pilot = "Thompson" OR "Velocity" >= 240.0 OR Date != "May 19, 1964" UNION SELECT Velocity, Pilot, airport_id, Altitude FROM flight WHERE Vehicle_Flight_number != "M2-F1 #39" AND "id" = 7 AND "airport_id" != 4 AND "company_id" = 7 AND Pilot <> "Thompson" AND Date != "March 1, 1963" OR "Velocity" > 240.0


Question: Can you give me a list of driver IDs that are less than 4 and also not equal to 9, considering only the driver IDs that appear in both the driver and school_bus tables?

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


Question: Can you give me a list of driver IDs that are both greater than or equal to 6 and not equal to 4, considering only the driver IDs present in both the driver and school_bus tables?

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


Question: Can you give me the register year, branch ID, and member ID for all members with an ID less than 7 who registered in 2016, combined with the register year, branch ID, and member ID for all members who registered in 2017 at branch 8 and whose member ID is not 2?

SELECT Register_Year, Branch_ID, Member_ID FROM membership_register_branch WHERE "Member_ID" < 7 AND Register_Year = "2016" UNION SELECT Register_Year, Branch_ID, Member_ID FROM membership_register_branch WHERE Register_Year = "2017" AND Branch_ID = "8" AND "Member_ID" <> 2


Question: Can you list the aircraft IDs that are greater than or equal to 2, grouping by ID from the aircraft table, and combine that with a list of aircraft IDs greater than 2, grouping by ID from the airport_aircraft table?

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


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

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


Question: Can you give me a list of driver IDs from the driver table where the driver ID is 8 or higher, combined with a list of driver IDs from the school bus table where the driver ID is exactly 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: What aircraft IDs, excluding aircraft ID 1, are present in both the aircraft table and the airport_aircraft table, where only aircraft IDs greater than 3 are considered in the airport_aircraft table?

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


Question: Can you give me a list of all aircraft IDs, excluding aircraft ID 3, from both the aircraft and airport aircraft lists?

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


Question: Can you give me a list of driver IDs from the driver table where each ID is less than or equal to 4, combined with a list of driver IDs from the school_bus table where each ID is less than 3?

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


Question: Can you give me a list of driver IDs, excluding driver ID 12, that are not also driver IDs greater than or equal to 3 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 >= 3


Question: Can you give me the driver IDs that are both less than 10 and appear in the driver table, and also less than or equal to 7 and appear 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: Can you give me a list of driver IDs that are both less than or equal to 3 and also less than 9, considering only unique 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 < 9


Question: Can you give me a list of template type codes, including those that are not CV from the template types table, and also those from the templates table where the effective date is February 20, 2005, the template details are not empty, or the effective end date is not April 18, 2001 and the template type code is AD?

SELECT Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Description <> "CV" UNION ALL SELECT Template_Type_Code FROM Templates WHERE Date_Effective_From = "2005-02-20 00:31:34" OR Template_Details <> "" OR Date_Effective_To != "2001-04-18 09:29:52" AND Template_Type_Code = "AD"


Question: Could you list the weight and PetID for all pets, including those with a PetID of 2001 or those that are dogs and not one year old, along with those that weigh 13.4 or less, are not two years old, and are not dogs?

SELECT weight, PetID FROM Pets WHERE "PetID" = 2001 OR "pet_age" != 1 AND PetType = "dog" UNION ALL SELECT weight, PetID FROM Pets WHERE "weight" <= 13.4 AND "pet_age" <> 2 AND PetType != "dog"


Question: Which driver IDs appear in both the driver list, excluding driver ID 5, and the school bus list, including only driver IDs greater than or equal to 7?

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


Question: Can you give me a list of driver IDs that are at least 3, excluding those driver IDs that are also in the school bus list and are at least 7?

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


Question: Can you give me a list of driver IDs, including driver ID 1 from the driver table and all driver IDs except 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: Can you give me a list of driver IDs that are less than 10 from the driver table, combined with a list of driver IDs that are less than 3 from the school bus table, removing any duplicates?

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

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


Question: Can you give me a list of driver IDs that are both less than or equal to 12 and not equal to 9, considering only the driver IDs that appear in both the driver and school bus tables?

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


Question: Can you give me a list of driver IDs, including driver ID 11 from the driver table, and all driver IDs from the school bus table except for driver ID 4?

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


Question: Can you show me the lowest Club ID and the rank of coaches, excluding Joe Fabbri and clubs in Korea, and only including those who started in 2005 or later with a rank of 5 or less, or those who coach BK Häcken, or are not male, or have a Coach ID other than 3?

SELECT MIN(T1.Club_ID), T2.Rank FROM club as T1 JOIN coach as T2 ON T1.Club_ID = T2.Club_ID WHERE Coach_name <> "Joe Fabbri" AND Region <> "Korea" AND "Start_year" >= 2005 AND "Rank" <= 5 OR Club_name = "BK Häcken" OR Gender <> "M" OR "Coach_ID" <> 3


Question: Can you give me a list of driver IDs less than or equal to 8, excluding any driver IDs that are not equal to 7 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 <> 7


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

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


Question: Can you give me a list of driver IDs, excluding driver ID 7, that appear in the driver table but not in the school_bus table?

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


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

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


Question: Can you give me the company ID, total group equity shareholding, principal activities, and earliest incorporation date for companies that meet both of these conditions: either they are not subsidiaries, or their group equity shareholding is 30% or less, or their ID is 12 or less; and also, either their principal activities are not catering services, or their ID is 14, or they are not subsidiaries, or their name is Cathay Pacific Catering Services (HK) Limited, or their group equity shareholding is exactly 100%, or they were incorporated in China?

SELECT id, SUM(Group_Equity_Shareholding), Principal_activities, MIN(Incorporated_in) FROM operate_company WHERE Type != "Subsidiary" OR "Group_Equity_Shareholding" <= 30.0 OR "id" <= 12 INTERSECT SELECT id, SUM(Group_Equity_Shareholding), Principal_activities, MIN(Incorporated_in) FROM operate_company WHERE Principal_activities <> "Catering services" OR "id" = 14 OR Type != "Subsidiary" OR name = "Cathay Pacific Catering Services (HK) Limited" OR "Group_Equity_Shareholding" = 100.0 OR Incorporated_in = "China"


Question: Which aircraft IDs are not equal to 3 and are also greater than 2?

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: Can you give me a list of driver IDs, excluding driver ID 2 from the driver table and driver ID 9 from the school_bus table, making sure to list each driver ID only once?

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: Can you give me a list of student IDs, including those with allergies excluding student 1027, and also those students from the student table who are not from Hong Kong or whose first name is not Jun?

SELECT StuID FROM Has_Allergy WHERE "StuID" <> 1027 UNION SELECT StuID FROM Student WHERE city_code <> "HKG" OR Fname != "Jun"


Question: Which driver IDs are greater than 2 and also not equal to 7?

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


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

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


Question: Can you give me the driver ID, if it's equal to 9, but only if that driver ID is not also less than 9 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 < 9


Question: What is the total of the property type codes from properties that were not sold on January 31, 1995 at 11:18:42 AM and had a vendor requested price of 2219.6778 and a property ID of 3 or greater, or had a third other feature that was not "None" and a first other feature of "None", or had a buyer offered price of 2.0 or less and an agreed selling price other than 4514.807, or had a second other feature that was not "None" and a third shop feature of "None", or had a second house feature of "None", or had more than 5 rooms and a property type code other than "Apartment", or had a first field feature that was not "None", or had a second field feature that was not "None", combined with the total of the property type codes from property types that are not "Other" and have a property type description that is not "Shop, Retail Outlet."?

SELECT SUM(property_type_code) FROM Properties WHERE date_sold <> "1995-01-31 11:18:42" AND "vendor_requested_price" = 2219.6778 AND "property_id" >= 3 OR oth_feature_3 <> "None" AND oth_feature_1 = "None" OR "buyer_offered_price" <= 2.0 AND "agreed_selling_price" <> 4514.807 OR oth_feature_2 <> "None" AND shp_feature_3 = "None" OR hse_feature_2 = "None" OR "room_count" > 5 AND property_type_code <> "Apartment" OR fld_feature_1 <> "None" OR fld_feature_2 <> "None" UNION SELECT SUM(property_type_code) FROM Ref_Property_Types WHERE property_type_code <> "Other" AND property_type_description != "Shop, Retail Outlet."


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

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


Question: Can you give me a list of driver IDs that are less than 8 and also appear in the list of school bus driver IDs, excluding driver ID 7?

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 is the difference between the total document ID of documents with shipping agent code AL and receipt number 61, or document ID not equal to 13 and other details not equal to h and receipt date not equal to 2008-04-21 20:42:25, or document status code working, or document type code not equal to Paper, and the total document ID of draft copies with document ID greater than 23 and copy number not equal to 5 and draft number not equal to 8?

SELECT SUM(document_id) FROM Documents WHERE shipping_agent_code = "AL" AND receipt_number = "61" OR "document_id" != 13 AND other_details != "h" AND receipt_date <> "2008-04-21 20:42:25" OR document_status_code = "working" OR document_type_code <> "Paper" EXCEPT SELECT SUM(document_id) FROM Draft_Copies WHERE "document_id" > 23 AND "copy_number" != 5 AND "draft_number" != 8


Question: What is the average template detail value that satisfies both of these conditions: either the template ID is 25, or the effective date is not 2001-04-18 09:29:52, the template type is not PP, the template details are empty, and the version number is less than 7; and also, the effective date is not 1986-11-14 12:20:18, the template details are not empty, the version number is less than or equal to 0, or the template type is not PP?

SELECT AVG(Template_Details) FROM Templates WHERE "Template_ID" = 25 OR Date_Effective_To != "2001-04-18 09:29:52" AND Template_Type_Code != "PP" AND Template_Details = "" AND "Version_Number" < 7 INTERSECT SELECT AVG(Template_Details) FROM Templates WHERE Date_Effective_From != "1986-11-14 12:20:18" AND Template_Details <> "" OR "Version_Number" <= 0 OR Template_Type_Code != "PP"


Question: Which driver IDs are both not equal to 5 and less than 10?

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


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

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


Question: Can you list the district IDs from the district table, excluding those headquartered in Bahawalpur City or named Chakwal District, but including those with a District ID of 3 or greater, or a City Area of 12.0 or greater, or a City Population greater than 172073, and then remove any district IDs that appear in the store_district table where the Store ID is 5 or the District ID is not 3?

SELECT District_ID FROM district WHERE Headquartered_City <> "Bahawalpur City" AND District_name <> "Chakwal District" AND "District_ID" >= 3 AND "City_Area" >= 12.0 OR "City_Population" > 172073.0 EXCEPT SELECT District_ID FROM store_district WHERE "Store_ID" = 5 OR "District_ID" != 3


Question: Can you give me a list of customer IDs from the Customer_Payments table where the customer ID is less than 13, or the payment date and time is March 12, 2018 at 8:41:47 AM and the payment method is not Direct Debit, combined with a list of customer IDs from the Customers table where the customer status is "Good Customer", or the first name is not "Rylan" and the phone number is +14(5)2351480248 and the customer ID is not 12?

SELECT customer_id FROM Customer_Payments WHERE "customer_id" < 13 OR datetime_payment = "2018-03-12 08:41:47" AND payment_method_code != "Direct Debit" UNION ALL SELECT customer_id FROM Customers WHERE customer_status_code = "Good Customer" OR first_name != "Rylan" AND phone_number = "+14(5)2351480248" AND "customer_id" <> 12


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

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


Question: Can you show me the pet type, ID, and weight for all pets, including those that are not 3 years old or are not dogs, combined with those that don't weigh 9.3, don't have an ID of 2002, and aren't dogs?

SELECT PetType, PetID, weight FROM Pets WHERE "pet_age" <> 3 OR PetType <> "dog" UNION SELECT PetType, PetID, weight FROM Pets WHERE "weight" != 9.3 AND "PetID" != 2002 AND PetType != "dog"


Question: What are the total disk areas of aircraft and the corresponding airport IDs where those aircraft are located?

SELECT T1.Total_disk_area, T2.Airport_ID FROM aircraft as T1 JOIN airport_aircraft as T2 ON T1.Aircraft_ID = T2.Aircraft_ID


Question: Can you give me the IDs of drivers, up to and including ID 4, excluding the IDs of school bus drivers up to ID 8?

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


Question: Could you give me a list of driver IDs that are not equal to 1 and are also greater than or equal to 9, considering both the driver and school bus records?

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


Question: Can you give me the IDs of books that are not titled "Cyberella" and are written by "Christopher Hinz", or have more than 6 issues, but exclude any book IDs that are in publications with a Publication ID of 5 or less?

SELECT Book_ID FROM book WHERE Title != "Cyberella" AND Writer = "Christopher Hinz" OR "Issues" > 6.0 EXCEPT SELECT Book_ID FROM publication WHERE "Publication_ID" <= 5


Question: Which aircraft IDs are not equal to 4 and also have an aircraft ID greater than 2 in the airport aircraft table?

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


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

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


Question: Can you give me a list of aircraft IDs that are greater than 3 and also not equal to 2, considering 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: Can you give me a list of driver IDs, including those from the driver table excluding driver ID 9, and also including driver ID 3 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 = 3


Question: Could you give me a list of driver IDs, including driver ID 5 from the driver table, and any driver IDs greater than 7 from the school bus table?

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


Question: Which driver IDs are not equal to 2 and are also equal to 10?

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


Question: Which driver has an ID of 3 and also drives a school bus, but is not driver number 9?

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


Question: What is the highest club ID and the gender of coaches, grouped by start year, considering only clubs and coaches where either the gender is male, or the club name is not Gefle IF and the coach's name is James Wong, or the start year is 2011 or earlier, or the region is the UK, or the rank is 1 or less and the coach ID is 4 or greater, and then filtering these groups to only include those where either the club name is not Halmstads BK, or the coach's name is Joe Fabbri and the start year is before 2009, or the region is the USA, or the rank is less than 3, or the coach ID is 2 or less, or the gender is male?

SELECT MAX(T1.Club_ID), T2.Gender FROM club as T1 JOIN coach as T2 ON T1.Club_ID = T2.Club_ID WHERE Gender = "M" OR Club_name <> "Gefle IF" AND Coach_name = "James Wong" OR "Start_year" <= 2011 OR Region = "UK" OR "Rank" <= 1 AND "Coach_ID" >= 4 GROUP BY Start_year HAVING Club_name <> "Halmstads BK" OR Coach_name = "Joe Fabbri" AND Start_year < 2009 OR Region = "USA" OR Rank < 3 OR Coach_ID <= 2 OR Gender = "M"


Question: Which driver IDs are both not equal to 2 and less than or equal to 4?

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


Question: Can you give me the gender, occupation, highest residence value, votes, rank, sponsor name, and total player name count for players, combining two sets of results: first, those who are not sponsored by "Winnipeg South", are not ranked "2nd", or are not named "Matt Schaubroeck" and also have a player ID of 5 or less, live in Winnipeg, are not male, are not a "Small Businessman", and have a vote count other than 2353; and second, those who are not ranked "3rd" and live in Winnipeg, or are named "Jean Luc Bouché" and are not a "Product Consultant - MLCC", or are not sponsored by "Brandon—Souris" and are not female?

Gender Occupation MAX(Residence) Votes Rank Sponsor_name SUM(Player_name)

SELECT Gender, Occupation, MAX(Residence), Votes, Rank, Sponsor_name, SUM(Player_name) FROM player WHERE Sponsor_name != "Winnipeg South" OR Rank <> "2nd" OR Player_name != "Matt Schaubroeck" AND "Player_ID" <= 5 AND Residence = "Winnipeg" AND Gender != "M" AND Occupation <> "Small Businessman" AND "Votes" != 2353 UNION SELECT Gender, Occupation, MAX(Residence), Votes, Rank, Sponsor_name, SUM(Player_name) FROM player WHERE Rank != "3rd" AND Residence = "Winnipeg" OR Player_name = "Jean Luc Bouché" AND Occupation <> "Product Consultant - MLCC" OR Sponsor_name != "Brandon—Souris" AND Gender != "F"


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

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


Question: Can you give me a list of driver IDs that are less than 2, excluding any driver IDs that are also less than 9 and appear in the school bus records?

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


Question: Can you give me a list of driver IDs that are less than 6, but exclude the driver ID 3 if it appears 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 = 3


Question: Can you give me the total ID number and horsepower for car makers and cars, grouped by the car maker's full name, considering only cars with more than 4 cylinders or a 0-60 time of 18 seconds or more, and then filtering this further to only include groups where the number of cylinders is less than 6 or the year is after 1970 or the country isn't 1 or the MPG isn't 16 and the engine displacement is more than 140 or the maker isn't Opel and the weight is 2904, while also excluding cars with 105 horsepower?

SELECT SUM(T1.Id), T2.Horsepower FROM car_makers as T1 JOIN cars_data as T2 ON T1.Id = T2.Id WHERE "Cylinders" > 4 AND Horsepower <> "105" OR "Accelerate" >= 18.0 GROUP BY FullName HAVING Cylinders < 6 AND Year > 1970 OR Country <> "1" OR MPG <> "16" AND Edispl > 140.0 OR Maker <> "opel" AND Weight = 2904


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

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


Question: Can you give me a list of driver IDs, excluding driver ID 4, that are not also driver IDs greater than or equal to 3 found in the school bus table?

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


Question: Which driver IDs appear in the driver table, excluding driver ID 5, and also appear in the school_bus table as driver ID 7?

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


Question: Can you give me a list of driver IDs that are at least 1, excluding those driver IDs less than 4 that are also in the school bus list?

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


Question: Can you list the aircraft IDs that are greater than or equal to 5, excluding any aircraft IDs that are equal to 2 in the airport aircraft table?

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


Question: What template type codes, excluding "PP" and those with the description "Book", are not also template type codes used in templates with the code "AD"?

SELECT Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Code != "PP" AND Template_Type_Description != "Book" EXCEPT SELECT Template_Type_Code FROM Templates WHERE Template_Type_Code = "AD"


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

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


Question: Which driver IDs, excluding driver ID 2, are also driver ID 3?

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


Question: Can you give me a list of company IDs, including those from the company table where either the assets are less than 292.5 billion, the name isn't "Industrial and Commercial Bank of China", the company ID isn't 16 and the industry isn't "Retailing", the headquarters isn't in the Netherlands and the market value is greater than 227.6 billion, or the sales are not 145.9 billion, combined with company IDs from the employment table where the company ID is greater than or equal to 15 or the years working are greater than or equal to 2?

SELECT Company_ID FROM company WHERE "Assets_in_Billion" < 292.5 OR Name != "Industrial and Commercial Bank of China" OR "Company_ID" <> 16.0 AND Industry <> "Retailing" OR Headquarters != "Netherlands" AND "Market_Value_in_Billion" > 227.6 OR "Sales_in_Billion" != 145.9 UNION SELECT Company_ID FROM employment WHERE "Company_ID" >= 15 OR "Year_working" >= 2


Question: Could you list the aircraft IDs that are less than 4 when grouped in the aircraft table, but also less than or equal to 3 when grouped 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: Which driver IDs, excluding driver ID 4, are also driver IDs less than or equal to 3 in the school bus list?

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


Question: Can you give me a list of all Driver IDs, excluding the ID 10, that appear in either the driver table or 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 <> 10


Question: Can you list all the Big Silver values from the match results, including those where the rank is less than 5, the Club ID is less than 3, the Gold is 20 or less, or the Points are greater than 89, and also including those where the Club ID is 5 or the Bronze is 7 or more?

SELECT Big_Silver FROM match_result WHERE "Rank" < 5 OR "Club_ID" < 3 OR "Gold" <= 20 OR "Points" > 89 UNION ALL SELECT Big_Silver FROM match_result WHERE "Club_ID" = 5 OR "Bronze" >= 7


Question: Which driver IDs are less than 8 and also equal to 7 in the school bus records?

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


Question: Which driver IDs, excluding 10, are also driver IDs greater than 7 in the school bus list?

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


Question: Can you list the aircraft IDs that are less than 5 from the aircraft table, combined with the aircraft IDs that are greater than 2 from the airport_aircraft table, removing any duplicates?

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: Can you give me a list of document IDs from the drafts table, including those where the draft details are not "w", and also including those where the draft details are not "v" and either the document ID is greater than or equal to 12 or the draft number is not 10?

SELECT document_id FROM Document_Drafts WHERE draft_details != "w" UNION ALL SELECT document_id FROM Document_Drafts WHERE draft_details <> "v" AND "document_id" >= 12 OR "draft_number" != 10


Question: What is the highest member ID of members who are not from Fort Campbell, Kentucky and are at level 6, excluding the highest member ID from purchases made in 2018?

SELECT MAX(Member_ID) FROM member WHERE Hometown <> "Fort Campbell, Kentucky" AND "Level" = 6 EXCEPT SELECT MAX(Member_ID) FROM purchase WHERE Year = "2018"


Question: Can you give me a list of driver IDs that are both less than or equal to 9 and not equal to 7, considering only the unique driver IDs from the driver and school_bus tables?

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


Question: Can you show me the salary, employee ID, and name of all employees whose salary is not 256481, excluding those employees named Larry West with a salary greater than 152013, or those with an employee ID not equal to 573284895?

SELECT salary, eid, name FROM employee WHERE "salary" <> 256481 EXCEPT SELECT salary, eid, name FROM employee WHERE name = "Larry West" AND "salary" > 152013 OR "eid" != 573284895


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

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


Question: What is the total of all car maker IDs from car_makers where the country code is 6, or where the ID is less than or equal to 18 and the maker is not peugeaut, combined with the total of all car IDs from cars_data where the MPG is not 16, and the accelerate value is 15.0, and the ID is not 3, and the year is before 1974, or the engine displacement is 140.0?

SELECT SUM(Id) FROM car_makers WHERE Country = "6" OR "Id" <= 18 AND Maker <> "peugeaut" UNION ALL SELECT SUM(Id) FROM cars_data WHERE MPG != "16" AND "Accelerate" = 15.0 AND "Id" != 3 AND "Year" < 1974 OR "Edispl" = 140.0


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

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


Question: Can you list all the aircraft IDs, excluding aircraft ID 5, and also list aircraft ID 2 from the airport aircraft?

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


Question: Can you give me a list of driver IDs from the driver table that are greater than or equal to 3, excluding any driver IDs from the school_bus table that are not equal to 4?

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


Question: Can you give me a list of driver IDs that are less than 11 and also greater than or equal to 3, considering driver IDs from 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 aircraft IDs that are greater than or equal to 1, excluding those aircraft IDs that are less than 5 and are present in the airport aircraft list?

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: Can you list all the aircraft IDs, combining those from the aircraft table that are greater than or equal to 1 with those from the airport_aircraft table that are not equal to 3?

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


Question: Can you give me a list of driver IDs, combining those from the driver table excluding driver ID 7, and those from the school bus table that are less than 9?

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


Question: Can you give me a list of all driver IDs, combining those from the driver table excluding ID 4 with those from the school bus table excluding ID 10?

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


Question: Can you give me the driver ID that appears exactly once, where the driver ID is 8 in the driver table, but is not a driver ID less than 7 in the school bus table?

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


Question: Can you give me a list of driver IDs that are both not equal to 1 and also less than or equal to 10?

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


Question: Could you list the address IDs and details for all addresses with an ID of 1 or greater, and also include the address IDs and details for addresses that don't have "IT" as their details and have an ID less than 5?

SELECT address_id, address_details FROM Addresses WHERE "address_id" >= 1 UNION ALL SELECT address_id, address_details FROM Addresses WHERE address_details <> "IT" AND "address_id" < 5


Question: Can you give me a list of driver IDs, including those from the driver table excluding driver ID 12, and those from the school bus table with driver IDs of 3 or higher?

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


Question: Can you give me the altitude, airport ID, velocity, and flight number for flights where the altitude is at least 3650 or the flight number is "M2-F1 #61" and the company ID is greater than 4 and the ID is greater than 8, but exclude any flights where the date is not "September 3, 1963" or the pilot is not "Thompson" and the airport ID is less than 2?

SELECT Altitude, airport_id, Velocity, Vehicle_Flight_number FROM flight WHERE "Altitude" >= 3650.0 OR Vehicle_Flight_number = "M2-F1 #61" AND "company_id" > 4 AND "id" > 8 EXCEPT SELECT Altitude, airport_id, Velocity, Vehicle_Flight_number FROM flight WHERE Date <> "September 3, 1963" OR Pilot <> "Thompson" AND "airport_id" < 2


Question: Can you list all aircraft IDs that are less than 5 from the aircraft table, and also list all aircraft IDs that are less than or equal to 2 from the airport_aircraft table, combining the two lists into one?

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: Can you give me a list of driver IDs that are less than 2, excluding any driver IDs that are equal to 4 in the school bus list?

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


Question: Can you give me a list of aircraft IDs, excluding aircraft ID 3, that appear in the aircraft table but not in the airport_aircraft table, also excluding aircraft ID 1 from the airport_aircraft table?

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


Question: What is the longest paragraph text and its document ID, excluding paragraph ID 241, combined with the longest paragraph text and document ID where the paragraph text is not "Senegal"?

SELECT MAX(Paragraph_Text), Document_ID FROM Paragraphs WHERE "Paragraph_ID" != 241 UNION SELECT MAX(Paragraph_Text), Document_ID FROM Paragraphs WHERE Paragraph_Text <> "Senegal"


Question: What environmental allergies, excluding anchovies, are not also animal allergies, excluding eggs?

SELECT AllergyType, Allergy FROM Allergy_Type WHERE Allergy != "Anchovies" AND AllergyType = "environmental" EXCEPT SELECT AllergyType, Allergy FROM Allergy_Type WHERE Allergy != "Eggs" AND AllergyType = "animal"


Question: Can you give me a list of driver IDs that are both less than or equal to 10 and also greater than or equal to 3, considering only the unique driver IDs from the driver and school bus lists?

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


Question: Can you give me the hometown, name, level, and card number for all members, including those who either don't live in Red Jacket, West Virginia and have a Member ID less than 6, or have a card number that isn't FS10, along with all members who either don't have a Member ID of 8, or have a level that isn't 6 and a card number that isn't LCB7?

SELECT Hometown, Name, Level, Card_Number FROM member WHERE Hometown <> "Red Jacket, West Virginia" AND "Member_ID" < 6 OR Card_Number <> "FS10" UNION ALL SELECT Hometown, Name, Level, Card_Number FROM member WHERE "Member_ID" <> 8 OR "Level" != 6 AND Card_Number != "LCB7"


Question: Can you list the aircraft IDs that are greater than or equal to 4 from the aircraft table, and also list the aircraft IDs that are less than or equal to 2 from the airport_aircraft table?

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


Question: Can you give me a list of driver IDs from the driver table where the driver ID is 6 or greater, combined with a list of driver IDs from the school bus table where the driver ID is exactly 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: Can you give me a list of driver IDs that are greater than or equal to 2 from the driver table, combined with a list of driver IDs that are greater than or equal to 9 from the school bus table?

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


Question: Which driver IDs are not equal to 3 and also not equal to 7 in the school bus driver list?

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 total distance of aircraft flights where either the distance is at least 4010 and the aircraft ID is 3, or the aircraft name is Boeing 777-300, combined with the total distance of flights where either the origin is not Los Angeles and the flight number is less than 13, or the destination is Sydney and the price is less than 220.98, or the aircraft ID is less than 7 and the arrival date is 04/12/2005 03:18 and the departure date is 04/12/2005 08:32?

SELECT SUM(distance) FROM aircraft WHERE "distance" >= 4010 AND "aid" = 3 OR name = "Boeing 777-300" UNION SELECT SUM(distance) FROM flight WHERE origin != "Los Angeles" AND "flno" < 13 OR destination = "Sydney" AND "price" < 220.98 OR "aid" < 7 AND arrival_date = "04/12/2005 03:18" AND departure_date = "04/12/2005 08:32"


Question: Can you give me the total of all birth dates, the amount outstanding, the total of all customer sign-up dates, the latest first name, the number of last names, the earliest customer address ID, the email address, the earliest phone number, and the earliest customer status code for all customers, combining results from two groups: first, those who are bad customers with an amount outstanding less than 2099, or whose first name is not Amya and last name is not Trantow, or whose customer address ID is 1, or whose customer ID is less than 10 and birth date is July 9th, 1993, around 11:11 AM, or whose phone number is not (729)396-4354x3576, or whose email address is not mariela28@example.org, or whose cell phone number is not 577-584-4864; and second, those whose birth date is not February 7th, 1993, around 5:40 AM, or whose amount outstanding is not 9447 and sign-up date is not May 13th, 2016, around 7:38 AM and phone number is not (662)490-3108, or whose cell phone number is 578-518-4785x612 and customer address ID is 10 or greater?

SELECT SUM(date_of_birth), amount_outstanding, SUM(date_became_customer), MAX(first_name), COUNT(last_name), MIN(customer_address_id), email_address, MIN(phone_number), MIN(customer_status_code) FROM Customers WHERE customer_status_code = "Bad Customer" AND "amount_outstanding" < 2099.0 OR first_name != "Amya" AND last_name != "Trantow" OR "customer_address_id" = 1 OR "customer_id" < 10 AND date_of_birth = "1993-07-09 11:11:36" OR phone_number <> "(729)396-4354x3576" OR email_address != "mariela28@example.org" OR cell_mobile_phone_number != "577-584-4864" UNION SELECT SUM(date_of_birth), amount_outstanding, SUM(date_became_customer), MAX(first_name), COUNT(last_name), MIN(customer_address_id), email_address, MIN(phone_number), MIN(customer_status_code) FROM Customers WHERE date_of_birth <> "1993-02-07 05:40:26" OR "amount_outstanding" != 9447.0 AND date_became_customer != "2016-05-13 07:38:23" AND phone_number <> "(662)490-3108" OR cell_mobile_phone_number = "578-518-4785x612" AND "customer_address_id" >= 10


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

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


Question: Can you list the aircraft IDs that are less than 3, excluding those aircraft IDs from the airport that are greater than or equal to 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: Can you give me a list of driver IDs that are greater than 9, excluding those driver IDs that are less than or equal to 3 and are also in the school bus list?

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


Question: Can you list the aircraft IDs, where each ID is greater than or equal to 1, excluding any aircraft IDs that are equal to 2 and also appear in the airport aircraft list?

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: Can you list the aircraft IDs from the aircraft table that are less than or equal to 1, and combine that with a list of aircraft IDs from the airport_aircraft table that are greater than 1?

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


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

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


Question: Can you give me a list of driver IDs, where each ID is 6 or greater, but only include the IDs that are not also in a list of school bus driver IDs that are 9 or greater?

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


Question: Can you list all aircraft IDs, making sure to include those from the aircraft table where the ID is not 1, and also those from the airport_aircraft table where the ID is not 3?

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


Question: Can you list the aircraft IDs that are greater than 3, and also list the aircraft IDs from the airport aircraft that are less than 1?

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


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


Question: Can you give me a list of company IDs, including those from companies with sales of at least 433.5 billion or those in the oil and gas industry, as well as company IDs from the employment table where the People ID is not 4?

SELECT Company_ID FROM company WHERE "Sales_in_Billion" >= 433.5 OR Industry = "Oil and gas" UNION ALL SELECT Company_ID FROM employment WHERE "People_ID" <> 4


Question: Can you give me a list of all Driver IDs, including those from the driver table where the ID is 12 or greater, and those from the school_bus table where the ID is not 10?

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


Question: What aircraft IDs are both greater than or equal to 2 in the aircraft table and not equal to 2 in the airport_aircraft table?

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


Question: Can you list all the address details that are not "US", or where the address ID is 2, and also list all address details that are not "DE"?

SELECT address_details FROM Addresses WHERE address_details <> "US" OR "address_id" = 2 UNION ALL SELECT address_details FROM Addresses WHERE address_details <> "DE"


Question: Can you give me a list showing the gender, coach name, and club ID for all coaches, including those with a coach ID greater than 5 and a club ID of 1 or higher, as well as those with a coach ID less than 5?

SELECT Gender, Coach_name, Club_ID FROM coach WHERE "Coach_ID" > 5 AND "Club_ID" >= 1 UNION SELECT Gender, Coach_name, Club_ID FROM coach WHERE "Coach_ID" < 5


Question: What are the average total pounds, member IDs, earliest branch IDs, and latest years for purchases made at branch 2, excluding those averages, IDs, branch IDs, and years from purchases where the total pounds are less than or equal to 343.76 and the member ID is less than 3, or the year isn't 2018, or the branch ID isn't 2?

SELECT AVG(Total_pounds), Member_ID, MIN(Branch_ID), MAX(Year) FROM purchase WHERE Branch_ID = "2" EXCEPT SELECT AVG(Total_pounds), Member_ID, MIN(Branch_ID), MAX(Year) FROM purchase WHERE "Total_pounds" <= 343.76 AND "Member_ID" < 3 OR Year != "2018" OR Branch_ID <> "2"


Question: Can you give me a list of driver IDs, including those from the driver table that are greater than 11, and those from the school_bus table that are less than 9?

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

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


Question: Can you list the aircraft IDs that are greater than 4 from the aircraft table, and combine that with a list of aircraft IDs that are not equal to 3 from the airport_aircraft table?

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


Question: Can you give me all the birth dates from the people table, including those where the name is not Aleksey Ostapenko, or the height is less than or equal to 207.0 and the nationality is not Russia, or the birth date is not April 17, 1987 and the People_ID is not 4, combined with all birth dates where the People_ID is not 1?

SELECT Birth_Date FROM people WHERE Name <> "Aleksey Ostapenko" OR "Height" <= 207.0 AND Nationality != "Russia" OR Birth_Date != "April 17, 1987" AND "People_ID" <> 4 UNION SELECT Birth_Date FROM people WHERE "People_ID" <> 1


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


Question: What is the smallest Template ID from the Documents table, excluding those with the description "k", combined with the smallest Template ID from the Templates table, considering entries where the Template Details are not empty and either the Version Number is not 2, the Template ID is greater than or equal to 9, or the Date Effective From is not "2002-08-25 13:26:23"?

SELECT MIN(Template_ID) FROM Documents WHERE Document_Description != "k" UNION ALL SELECT MIN(Template_ID) FROM Templates WHERE Template_Details <> "" AND "Version_Number" <> 2 OR "Template_ID" >= 9 OR Date_Effective_From <> "2002-08-25 13:26:23"


Question: Can you give me the rank, total gender count, number of coaches, coach name, and average club ID for coaches where either the club ID is greater than 3 and the gender is male, or the rank is greater than 2, combined with the same information for coaches where the rank is greater than 1 and the coach ID is less than 1, or the club ID is greater than or equal to 3, or the coach name is not Jameson Tomas and the gender is male?

SELECT Rank, SUM(Gender), COUNT(Coach_ID), Coach_name, AVG(Club_ID) FROM coach WHERE "Club_ID" > 3 AND Gender = "M" OR "Rank" > 2 UNION SELECT Rank, SUM(Gender), COUNT(Coach_ID), Coach_name, AVG(Club_ID) FROM coach WHERE "Rank" > 1 AND "Coach_ID" < 1 OR "Club_ID" >= 3 OR Coach_name != "Jameson Tomas" AND Gender = "M"


Question: Can you show me the Election ID, District, and earliest First Elected year for elections where either the Party is at least 2, or the Delegate is someone other than Gail H. Bates and the District is no more than 3, or the Committee is not Environmental Matters, or the First Elected year is before 2003 and the Election ID is not 1, combined with the Election ID, District, and earliest First Elected year for elections where the Party is no more than 2?

SELECT Election_ID, District, MIN(First_Elected) FROM election WHERE "Party" >= 2 OR Delegate != "Bates, Gail H. Gail H. Bates" AND "District" <= 3 OR Committee <> "Environmental Matters" OR "First_Elected" < 2003.0 AND "Election_ID" <> 1 UNION ALL SELECT Election_ID, District, MIN(First_Elected) FROM election WHERE "Party" <= 2


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

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


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


Question: Can you give me a list of coach names, including those with a Coach ID greater than 1 or a rank less than 3, and also those with a Coach ID greater than 4 or a Club ID less than 1 who are male, have a rank less than 2, and are not named Joe Fabbri?

SELECT Coach_name FROM coach WHERE "Coach_ID" > 1 OR "Rank" < 3 UNION ALL SELECT Coach_name FROM coach WHERE "Coach_ID" > 4 OR "Club_ID" < 1 AND "Rank" < 2 AND Gender = "M" AND Coach_name != "Joe Fabbri"


Question: Could you give me a list of document IDs from the Documents_Mailed table where either the mailed_to_address_id is less than 2, or the mailing date isn't April 1st, 1977 at 5:03 PM and the document ID is 14, combined with a list of document IDs where the mailing date is March 20th, 2007 at 5:22 AM?

SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" < 2 OR mailing_date != "1977-04-01 17:03:50" AND "document_id" = 14 UNION SELECT document_id FROM Documents_Mailed WHERE mailing_date = "2007-03-20 05:22:01"


Question: Can you give me the names and IDs of clubs that either don't have the description "Play pen and paper games on campus.", or don't have an ID of 2, or are named "Hopkins Student Enterprises", but only if they also have an ID less than or equal to 1, are named "Bootup Baltimore", and don't have the description "Venture capital fund for student business." or are located in "HHH"?

SELECT ClubName, ClubID FROM Club WHERE ClubDesc != "Play pen and paper games on campus." OR "ClubID" <> 2 OR ClubName = "Hopkins Student Enterprises" INTERSECT SELECT ClubName, ClubID FROM Club WHERE "ClubID" <= 1 AND ClubName = "Bootup Baltimore" AND ClubDesc <> "Venture capital fund for student business." OR ClubLocation = "HHH"


Question: Can you give me a list of driver IDs from the driver table where the driver ID is greater than 3, combined with a list of driver IDs from the school_bus table where the driver ID is greater 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: Can you give me a list of district IDs, combining those from districts that aren't named "Chakwal District," don't have a city population of 530438, have a district ID of 13 or greater, or aren't headquartered in "Gujranwala City," or have a city area less than 22, with district IDs from stores that don't have a store ID of 4?

SELECT District_ID FROM district WHERE District_name <> "Chakwal District" AND "City_Population" != 530438.0 AND "District_ID" >= 13 AND Headquartered_City <> "Gujranwala City" OR "City_Area" < 22.0 UNION SELECT District_ID FROM store_district WHERE "Store_ID" != 4


Question: Which driver IDs are not equal to 12 and also not equal to 10, considering both the driver and school bus records?

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: Can you show me the source user ID, target user ID, and trust values from the trust table, including entries where the source user ID is not 2 or the trust value is not 10, along with all entries where the trust value is less than 6?

SELECT source_u_id, target_u_id, trust FROM trust WHERE "source_u_id" <> 2 OR "trust" <> 10 UNION ALL SELECT source_u_id, target_u_id, trust FROM trust WHERE "trust" < 6


Question: Can you give me a list of driver IDs, combining those from the driver table excluding driver ID 7, and those from the school bus table that are less than or 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: What is the average country name for each continent, considering only countries with a CountryId of 13 or less, combined with the average country name for each continent, considering all countries except the one with CountryId 4?

SELECT Continent, AVG(CountryName) FROM countries WHERE "CountryId" <= 13 UNION ALL SELECT Continent, AVG(CountryName) FROM countries WHERE "CountryId" <> 4


Question: Can you give me a list of first names from the student records, including anyone who either doesn't live in PIT and has advisor 7134, or whose first name isn't Mark and is younger than 20, or whose last name isn't Jones, along with anyone whose major is 100 or higher, or isn't female, or has a student ID less than 1002, or has an advisor other than 8721 and a first name of Jun, or doesn't live in LOS and is older than 27?

SELECT Fname FROM Student WHERE city_code <> "PIT" AND "Advisor" = 7134 OR Fname <> "Mark" AND "Age" < 20 OR LName != "Jones" UNION ALL SELECT Fname FROM Student WHERE "Major" >= 100 OR Sex <> "F" OR "StuID" < 1002 OR "Advisor" != 8721 AND Fname = "Jun" OR city_code != "LOS" AND "Age" > 27


Question: What are the role descriptions and codes for roles that are not 'Editor', excluding those that are also not 'Photo'?

SELECT role_description, role_code FROM Roles WHERE role_description <> "Editor" EXCEPT SELECT role_description, role_code FROM Roles WHERE role_description <> "Photo"


Question: Which driver IDs are both not equal to 7 in the driver table and greater than 7 in the school_bus table?

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


Question: What is the lowest rank in the match results where the points are 168, the small silver is 6 or less, the gold is less than 12, the club ID is greater than 1, or the bronze is 10 or less, or the big silver is not 11, combined with the lowest rank of all players excluding player ID 5?

SELECT MIN(Rank) FROM match_result WHERE "Points" = 168 OR "Small_Silver" <= 6 OR "Gold" < 12 OR "Club_ID" > 1 OR "Bronze" <= 10 OR "Big_Silver" != 11 UNION ALL SELECT MIN(Rank) FROM player WHERE "Player_ID" <> 5


Question: Can you list all the aircraft IDs, excluding ID 4, from the aircraft table, and combine that with a list of aircraft IDs greater than or equal to 5 from the airport_aircraft table?

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


Question: Can you list all aircraft IDs, excluding aircraft ID 5, and also list all aircraft IDs from the airport aircraft table that are greater than or equal to 5?

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


Question: Can you give me a list of driver IDs, excluding driver ID 12, that are not also driver ID 7 in the school bus records?

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


Question: Can you give me the Aircraft IDs that appear exactly as '4' in the aircraft table, but are not Aircraft IDs less than or equal to '3' in the airport_aircraft table?

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


Question: Can you give me the IDs of drivers, where each ID is less than or equal to 4, excluding the driver ID 4 if it's also present in the school bus driver list?

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


Question: Can you give me a list of aircraft IDs, including those that appear in the aircraft table with an ID of 2, and also those that appear in the airport_aircraft table with an ID of 3 or higher?

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 feature type names and codes that are both named "Securiyt, eg Burglar Alarm." and have the code "Security"?

SELECT feature_type_name, feature_type_code FROM Ref_Feature_Types WHERE feature_type_name = "Securiyt, eg Burglar Alarm." INTERSECT SELECT feature_type_name, feature_type_code FROM Ref_Feature_Types WHERE feature_type_code = "Security"


Question: Could you give me the total ID number from car makers, along with the weight from car data, but only for entries where the full name is "American Motor Company," or the number of cylinders is less than 4 and the horsepower isn't "75," or the year is 1982 or earlier, or the acceleration is 16.5 or less and the weight isn't 2472, or the country isn't "8" and the maker isn't "toyota"?

SELECT SUM(T1.Id), T2.Weight FROM car_makers as T1 JOIN cars_data as T2 ON T1.Id = T2.Id WHERE FullName = "American Motor Company" OR "Cylinders" < 4 AND Horsepower <> "75" OR "Year" <= 1982 OR "Accelerate" <= 16.5 AND "Weight" <> 2472 OR Country <> "8" AND Maker <> "toyota"


Question: Can you give me a list of student IDs, last names, ages, majors, and the number of first names for students, combining two groups: first, those who don't have the first name "Jandy" or don't live in "LON" and have a major code of 600 or higher; and second, those who don't live in "HKG" and don't have the first name "William", or have a major code greater than 550?

SELECT StuID, LName, Age, Major, COUNT(Fname) FROM Student WHERE Fname != "Jandy" OR city_code != "LON" AND "Major" >= 600 UNION SELECT StuID, LName, Age, Major, COUNT(Fname) FROM Student WHERE city_code != "HKG" AND Fname != "William" OR "Major" > 550


Question: Which driver IDs are both not equal to 12 and less than 7?

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