Question: What are the shipping agent descriptions, codes, and names for shipping agents that are not named "Fedex" or have a description other than "t" and a code of "SH", combined with those agents that have a code of "SH" and a description other than "g"?

SELECT shipping_agent_description, shipping_agent_code, shipping_agent_name FROM Ref_Shipping_Agents WHERE shipping_agent_name != "Fedex" OR shipping_agent_description != "t" AND shipping_agent_code = "SH" UNION SELECT shipping_agent_description, shipping_agent_code, shipping_agent_name FROM Ref_Shipping_Agents WHERE shipping_agent_code = "SH" AND shipping_agent_description <> "g"


Question: What are the driver IDs greater than 4 from the driver table, combined with the driver IDs less than 7 from the school bus table?

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


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

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


Question: What are the template IDs from the Documents table that are not for "Customer reviews" and greater than 20, combined with the template IDs from the Templates table that are not 22, not of type "BK", and have different effective dates than "2001-04-18 09:29:52" and "1975-10-20 02:28:58"?

SELECT Template_ID FROM Documents WHERE Document_Name <> "Customer reviews" AND "Template_ID" > 20 UNION ALL SELECT Template_ID FROM Templates WHERE "Template_ID" != 22 AND Template_Type_Code <> "BK" AND Date_Effective_To <> "2001-04-18 09:29:52" AND Date_Effective_From <> "1975-10-20 02:28:58"


Question: For companies, find the profit in billions and the maximum market value in billions. Count the number of industries for each profit value. Consider companies where the profit is less than or equal to 14.4, or the name is not BP, or the headquarters is not in the USA.  From these, select only those profit values where the industry count is exactly one. Then, find the profit in billions and the maximum market value in billions. Count the number of industries for each profit value. Consider companies where the industry is not "Oil and gas", the headquarters is not in the Netherlands, and the sales are 147.3 billion, or the market value is not 180.0 billion, or the company ID is less than or equal to 15.0 and the assets are less than 209.5 billion. From these, select only those profit values where the maximum market value is greater than or equal to 147.4 billion and the industry count is at most one. Finally, give me the common profit values and maximum market values from both sets.

SELECT COUNT(Industry), Profits_in_Billion, MAX(Market_Value_in_Billion) FROM company WHERE "Profits_in_Billion" <= 14.4 OR Name != "BP" OR Headquarters != "USA" GROUP BY Profits_in_Billion HAVING COUNT(Industry) = 1 INTERSECT SELECT COUNT(Industry), Profits_in_Billion, MAX(Market_Value_in_Billion) FROM company WHERE Industry != "Oil and gas" AND Headquarters <> "Netherlands" AND "Sales_in_Billion" = 147.3 OR "Market_Value_in_Billion" != 180.0 OR "Company_ID" <= 15.0 AND "Assets_in_Billion" < 209.5 GROUP BY Profits_in_Billion HAVING MAX(Market_Value_in_Billion) >= 147.4 AND COUNT(Industry) <= 1


Question: What are the names and types of features that are not feature ID 3, but are also not described as "Burglar Alarm"?

SELECT feature_name, feature_type_code FROM Other_Available_Features WHERE "feature_id" != 3 EXCEPT SELECT feature_name, feature_type_code FROM Other_Available_Features WHERE feature_description <> "Burglar Alarm"


Question: What are the address details where the sum of address IDs is exactly 2, and also where the sum of address IDs is less than or equal to 2?

SELECT address_details, SUM(address_id) FROM Addresses GROUP BY address_details HAVING SUM(address_id) = 2 INTERSECT SELECT address_details, SUM(address_id) FROM Addresses GROUP BY address_details HAVING SUM(address_id) <= 2


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

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


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

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


Question: What are the aircraft IDs, excluding aircraft ID 4, and also the aircraft IDs less than 5, from the aircraft and airport aircraft tables?

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


Question: What are the driver IDs, excluding driver ID 3, and also the driver IDs greater than 9?

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


Question: What are the driver IDs, excluding driver ID 2, and also the driver IDs that are less than or equal to 4, from the driver and school bus tables?

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


Question: What is the sum of customer IDs, the maximum payment amount, the maximum payment date, and the payment method code for payments, excluding those made on "2018-02-06 13:35:58" or by customer 2, or with an amount less than 4773.16, but not including any payments where the amount was 4032.33 and the customer ID was less than 2?

SELECT SUM(customer_id), MAX(amount_payment), MAX(datetime_payment), payment_method_code FROM Customer_Payments WHERE datetime_payment != "2018-02-06 13:35:58" AND "customer_id" <> 2 AND "amount_payment" < 4773.16 EXCEPT SELECT SUM(customer_id), MAX(amount_payment), MAX(datetime_payment), payment_method_code FROM Customer_Payments WHERE "amount_payment" = 4032.33 AND "customer_id" < 2


Question: Which driver IDs are either less than or equal to 1, or greater than or equal to 7?

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


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

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


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

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


Question: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 2 from the driver table and including only driver IDs up to 4 from the school bus table?

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


Question: What are the driver IDs that are less than or equal to 6, excluding those driver IDs greater than 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: Find the template details and ID, along with the lowest version number, for templates effective until October 28, 1976, with empty details and type "PPT", but exclude those where the version number isn't 6 and the details aren't empty, or the type isn't "PP".

SELECT Template_Details, Template_ID, MIN(Version_Number) FROM Templates WHERE Date_Effective_To = "1976-10-28 10:08:50" AND Template_Details = "" AND Template_Type_Code = "PPT" EXCEPT SELECT Template_Details, Template_ID, MIN(Version_Number) FROM Templates WHERE "Version_Number" <> 6 AND Template_Details <> "" OR Template_Type_Code <> "PP"


Question: Which member IDs are associated with members who don't have card number "RE95" and have a level of 6 or less, or are from "Red Jacket, West Virginia", but are not member IDs from the membership register branch that have a member ID greater than or equal to 3 and registered in 2016, or have a branch ID of "4"?

SELECT Member_ID FROM member WHERE Card_Number <> "RE95" AND "Level" <= 6 OR Hometown = "Red Jacket, West Virginia" EXCEPT SELECT Member_ID FROM membership_register_branch WHERE "Member_ID" >= 3 AND Register_Year = "2016" OR Branch_ID = "4"


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

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


Question: What are all the trust values where the source user ID is less than or equal to 1, combined with trust values where the source user ID is less than 1 or the target user ID is 5 and the trust value is 7 or less?

SELECT trust FROM trust WHERE "source_u_id" <= 1 UNION ALL SELECT trust FROM trust WHERE "source_u_id" < 1 OR "target_u_id" = 5 AND "trust" <= 7


Question: What are the aircraft IDs that are greater than or equal to 4, excluding those aircraft IDs that are not equal to 5, based on the aircraft and airport_aircraft tables?

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


Question: Find the people IDs, the number of names, the number of nationalities, and the maximum height for people who were not born on August 8, 1986, grouped by people ID, where the maximum height is greater than 187.0. Exclude those people IDs, name counts, nationality counts, and maximum heights where the name isn't Sergey Grankin, or the nationality isn't Russia, or the people ID isn't 6, and the birth date isn't January 22, 1987, and the height is less than 187.0, grouped by people ID, with a name count less than or equal to 1.

People_ID COUNT(Name) COUNT(Nationality) MAX(Height)

SELECT People_ID, COUNT(Name), COUNT(Nationality), MAX(Height) FROM people WHERE Birth_Date <> "August 8, 1986" GROUP BY People_ID HAVING MAX(Height) > 187.0 EXCEPT SELECT People_ID, COUNT(Name), COUNT(Nationality), MAX(Height) FROM people WHERE Name != "Sergey Grankin" OR Nationality <> "Russia" OR "People_ID" != 6 AND Birth_Date != "January 22, 1987" AND "Height" < 187.0 GROUP BY People_ID HAVING COUNT(Name) <= 1


Question: Which driver IDs are less than or equal to 4, excluding those that are not equal to 10?

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


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

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


Question: Which driver IDs are greater than 8 and also present in the school bus table with IDs greater than or equal to 7?

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


Question: What are the shipping agent codes from the Documents table where the other details are "m" and the receipt date isn't "1973-11-05 21:48:53", or where the receipt number isn't "79" and the document status code isn't "overdue"? Also, what are the shipping agent codes from the Ref_Shipping_Agents table where the shipping agent code isn't "AL", or the shipping agent name isn't "UPS", or the shipping agent description isn't "t"? Combine both sets of results.

SELECT shipping_agent_code FROM Documents WHERE other_details = "m" AND receipt_date != "1973-11-05 21:48:53" OR receipt_number != "79" AND document_status_code <> "overdue" UNION ALL SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_code != "AL" OR shipping_agent_name <> "UPS" OR shipping_agent_description != "t"


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

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


Question: What are the IDs of people who have worked for a company for 2 years or less and have a company ID of 17 or less and a people ID of 2 or greater, or people with a people ID of 1 who did not graduate from Wisconsin–Stevens Point, are not from the United States, and are not named David Butler?

SELECT People_ID FROM employment WHERE "Year_working" <= 2 AND "Company_ID" <= 17 AND "People_ID" >= 2 UNION SELECT People_ID FROM people WHERE Graduation_College <> "Wisconsin–Stevens Point" AND "People_ID" = 1 AND Nationality != "United States" AND Name != "David Butler"


Question: What are the sum of last names, minimum customer ID, minimum date of becoming a customer, first name, customer address ID, count of customer status codes, average phone number, and sum of dates of birth for customers named Amya or those whose last name is not Koelpin, combined with the same information for customers where the amount outstanding is not 9500.0 and the first name is not Ray?

SELECT SUM(last_name), MIN(customer_id), MIN(date_became_customer), first_name, customer_address_id, COUNT(customer_status_code), AVG(phone_number), SUM(date_of_birth) FROM Customers WHERE first_name = "Amya" OR last_name <> "Koelpin" UNION SELECT SUM(last_name), MIN(customer_id), MIN(date_became_customer), first_name, customer_address_id, COUNT(customer_status_code), AVG(phone_number), SUM(date_of_birth) FROM Customers WHERE "amount_outstanding" != 9500.0 AND first_name <> "Ray"


Question: What states have an area code greater than 740 and are not MN, and also have votes where the vote ID is less than or equal to 2 and the phone number is 7148407040, or the contestant number is not 5?

SELECT state FROM AREA_CODE_STATE WHERE "area_code" > 740 AND state != "MN" INTERSECT SELECT state FROM VOTES WHERE "vote_id" <= 2 AND "phone_number" = 7148407040 OR "contestant_number" <> 5


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

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


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

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


Question: What are the driver IDs greater than 9 from the driver table, combined with the driver IDs greater than 10 from the school bus table?

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


Question: Which driver IDs are present in both the driver and school bus tables, excluding driver ID 5 from the driver table and driver ID 7 from the school bus table?

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


Question: Which contestant numbers are not Jessie Eichman and are less than 9, but are not in the votes where the vote was not created on "2018-03-09 19:03:36", or the vote ID is less than or equal to 5, or the phone number is greater than 6209222712?

SELECT contestant_number FROM CONTESTANTS WHERE contestant_name != "Jessie Eichman" AND "contestant_number" < 9 EXCEPT SELECT contestant_number FROM VOTES WHERE created <> "2018-03-09 19:03:36" OR "vote_id" <= 5 OR "phone_number" > 6209222712


Question: What states have an area code greater than 623 or are not Indiana, and also have vote IDs that are not 5?

SELECT state FROM AREA_CODE_STATE WHERE "area_code" > 623 OR state <> "IN" INTERSECT SELECT state FROM VOTES WHERE "vote_id" != 5


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

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


Question: What are the driver IDs, excluding driver ID 8, that are present in both the driver and school bus tables, where the driver ID in the school bus table is greater than 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: Which driver IDs are equal to 3, or are driver IDs from school buses not equal to 7?

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


Question: What are the driver IDs that are less than 4, and also the driver IDs from school buses that are less than 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: What are the IDs of drivers, excluding driver 4, and the IDs of school buses, excluding bus 7?

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: What are the other details from documents that are not document ID 4 and not "r", combined with the other details from employees who have the role code "ED" and an employee ID less than 8?

SELECT other_details FROM Documents WHERE "document_id" <> 4 AND other_details != "r" UNION SELECT other_details FROM Employees WHERE role_code = "ED" AND "employee_id" < 8


Question: What are the driver IDs that are greater than or equal to 2 in the driver table, combined with the driver ID 4 from the school bus table?

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


Question: What are the document IDs that meet at least one of the following conditions in the Documents table: a receipt date of September 27, 1982, at 2:52 PM and a document status that is not "done"; or a receipt number of "189" and other details of "h"; or a document type that is not "CD"; and also have a mailing date that is not January 14, 1982, at 5:50 AM in the Documents_Mailed table, excluding document ID 12?

SELECT document_id FROM Documents WHERE receipt_date = "1982-09-27 14:52:15" AND document_status_code != "done" OR receipt_number = "189" AND other_details = "h" OR document_type_code <> "CD" INTERSECT SELECT document_id FROM Documents_Mailed WHERE mailing_date != "1982-01-14 05:50:54" AND "document_id" != 12


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

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


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

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


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

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


Question: Which driver IDs are less than 5 but not equal to 4, considering only those driver IDs present in the 'driver' table and excluding those in the 'school_bus' table?

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


Question: What are the document IDs and copy numbers from the circulation history where the draft number isn't 17, the copy number is 5 or greater, or the employee ID is 1 or greater, or the document ID is less than 10, but exclude any document IDs and copy numbers from the draft copies table where the copy number is not 5?

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


Question: What are the driver IDs that are less than 12, and also the driver ID 9?

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


Question: What are the employee IDs of employees who are not named Tim Payne, combined with the employee IDs of those who are not full-time or have a Shop ID greater than 1?

SELECT Employee_ID FROM employee WHERE Name <> "Tim Payne" UNION SELECT Employee_ID FROM hiring WHERE Is_full_time <> "T" OR "Shop_ID" > 1


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

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


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

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


Question: What is the maximum Club ID and the gender, considering male coaches, coaches named James Wong, clubs started before or in 2011, clubs in the UK region, or coaches with a rank of 1 or less and a coach ID of 4 or greater?

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


Question: What is the average ClubID and the StuID for members of the "Bootup Baltimore" club?

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


Question: How many shops have employees other than employee ID 5 and are not full-time, excluding the number of shops in Jakobstad or with fewer than 6000 products or in the Lahden Stadion district and shop ID 3 or with a manager other than Mika Lehkosuo and a name other than IFK Mariehamn?

SELECT COUNT(Shop_ID) FROM hiring WHERE "Employee_ID" <> 5 AND Is_full_time != "T" EXCEPT SELECT COUNT(Shop_ID) FROM shop WHERE Location != "Jakobstad" OR "Number_products" < 6000 OR District != "Lahden Stadion" AND "Shop_ID" = 3 OR Manager_name <> "Mika Lehkosuo" AND Name <> "IFK Mariehamn"


Question: Which driver IDs, excluding ID 10, are present in the driver table, and also which driver IDs, up to and including ID 9, are present in the school bus table?

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


Question: What are the aircraft IDs that appear in both the aircraft and airport_aircraft tables, where the aircraft ID is 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: What is the average user ID for users with IDs less than 5, combined with the average user ID for users whose names are not Rosie?

SELECT AVG(u_id) FROM useracct WHERE "u_id" < 5 UNION SELECT AVG(u_id) FROM useracct WHERE name <> "Rosie"


Question: Which employee IDs meet these criteria: either the employee ID is 10, the age is greater than 32 and the city is not "Wasps", or the name is not "George Chuter", but are not in the hiring table with a start date other than "2008" or are not full-time and have an employee ID less than or equal to 2?

SELECT Employee_ID FROM employee WHERE "Employee_ID" = 10 OR "Age" > 32 AND City <> "Wasps" OR Name != "George Chuter" EXCEPT SELECT Employee_ID FROM hiring WHERE Start_from <> "2008" OR Is_full_time != "T" AND "Employee_ID" <= 2


Question: Which driver IDs are equal to 11 but not associated with a school bus ID other than 9?

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


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

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


Question: What is the lowest document status code for documents shipped by "UP", and what is the lowest document status code for "mailed late" documents that are also "working"?

SELECT MIN(document_status_code) FROM Documents WHERE shipping_agent_code = "UP" UNION SELECT MIN(document_status_code) FROM Ref_Document_Status WHERE document_status_description = "mailed late" AND document_status_code = "working"


Question: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 1 and any driver IDs less than 10?

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


Question: Which store IDs have fewer than 990 product categories, or are in a district other than 15, or have a store ID of 1?

SELECT Store_ID FROM store WHERE "Number_of_product_category" < 990.0 UNION ALL SELECT Store_ID FROM store_district WHERE "District_ID" != 15 OR "Store_ID" = 1


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

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


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

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


Question: What is the sum of majors, the minimum city code, and the age of students advised by advisor 5718 who are not 20 years old, excluding those who are not male and not named Eric, or whose last name is not Kim and have student ID 1015, or live in city code PHL, or have a major less than 600 and are younger than 20, or are advised by advisor 2192?

SELECT SUM(Major), MIN(city_code), Age FROM Student WHERE "Advisor" = 5718 AND "Age" != 20 EXCEPT SELECT SUM(Major), MIN(city_code), Age FROM Student WHERE Sex != "M" AND Fname != "Eric" OR LName <> "Kim" AND "StuID" = 1015 OR city_code = "PHL" OR "Major" < 600 AND "Age" < 20 OR "Advisor" = 2192


Question: Which driver IDs are either 9 or less than 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: What is the sum of coach IDs for coaches with ID less than or equal to 1 or club ID greater than 1, combined with the sum of coach IDs from player-coach records where the starting year is before or in 2012?

SELECT SUM(Coach_ID) FROM coach WHERE "Coach_ID" <= 1 OR "Club_ID" > 1 UNION ALL SELECT SUM(Coach_ID) FROM player_coach WHERE "Starting_year" <= 2012


Question: What is the average aid from the certificate table where the employee ID is less than or equal to 274878974, combined with the average aid from the flight table where the origin is not Los Angeles and the arrival date is not 04/12/2005 03:18 and the aid is not 3, or the flight number is greater than or equal to 7 and the destination is Chicago, or the price is not 202.45 and the departure date is not 04/12/2005 08:32?

SELECT AVG(aid) FROM certificate WHERE "eid" <= 274878974 UNION ALL SELECT AVG(aid) FROM flight WHERE origin <> "Los Angeles" AND arrival_date <> "04/12/2005 03:18" AND "aid" <> 3 OR "flno" >= 7 AND destination = "Chicago" OR "price" != 202.45 AND departure_date != "04/12/2005 08:32"


Question: What are the average employee ID, the count of cities, the count of ages, and the names of employees, meeting these conditions: the employee ID is not 2 and the age is not 36, grouped by name, where the count of cities is not 1 or the average employee ID is greater than 4.0, and also the average employee ID, the count of cities, the count of ages, and the names of employees, where the employee ID is greater than 3 or the age is not 36 and the city is not Bath and the name is Matt Stevens, grouped by name, where the average employee ID is greater than or equal to 8.0 and the count of ages is greater than or equal to 1 or the count of cities is less than 1?

AVG(Employee_ID) COUNT(City) COUNT(Age) Name

SELECT AVG(Employee_ID), COUNT(City), COUNT(Age), Name FROM employee WHERE "Employee_ID" <> 2 AND "Age" != 36 GROUP BY Name HAVING COUNT(City) <> 1 OR AVG(Employee_ID) > 4.0 INTERSECT SELECT AVG(Employee_ID), COUNT(City), COUNT(Age), Name FROM employee WHERE "Employee_ID" > 3 OR "Age" <> 36 AND City <> "Bath" AND Name = "Matt Stevens" GROUP BY Name HAVING AVG(Employee_ID) >= 8.0 AND COUNT(Age) >= 1 OR COUNT(City) < 1


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

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


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

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


Question: What are the driver IDs that are greater than 5 in the driver table and also less than 10 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 < 10


Question: What is the average name from the company table where profits are at most 20.1 billion, market value is at least 178.7 billion, and assets are not 1563.9 billion, or sales are at least 433.5 billion and the headquarters isn't in China, or the company ID is 15, and also the average name from the people table where the graduation college is not Northeastern, age is less than 37, and nationality is not United Kingdom?

SELECT AVG(Name) FROM company WHERE "Profits_in_Billion" <= 20.1 AND "Market_Value_in_Billion" >= 178.7 AND "Assets_in_Billion" <> 1563.9 OR "Sales_in_Billion" >= 433.5 AND Headquarters != "China" OR "Company_ID" = 15.0 INTERSECT SELECT AVG(Name) FROM people WHERE Graduation_College != "Northeastern" AND "Age" < 37 AND Nationality <> "United Kindom"


Question: What are the driver IDs that are equal to 5, and also the driver IDs that are less than 4?

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


Question: How many heads are there, along with their names and ages, where the age is less than 50, the name is Pádraig Harrington, and the head ID is 6 or less, or who were born in Connecticut? Also, how many heads are there, along with their names and ages, where the head ID is greater than 5, the name is not Stewart Cink, the birth state is not California, and the age is greater than 53?

SELECT COUNT(head_ID), name, age FROM head WHERE "age" < 50.0 AND name = "Pádraig Harrington" AND "head_ID" <= 6 OR born_state = "Connecticut" UNION ALL SELECT COUNT(head_ID), name, age FROM head WHERE "head_ID" > 5 AND name != "Stewart Cink" AND born_state != "California" AND "age" > 53.0


Question: Show me the best finish, poker player ID, if a final table was made, people ID, and money rank for poker players where the poker player ID is greater than 4 or the best finish is 3 or higher. Also, show the same information for poker players where the final table wasn't 26, the poker player ID is greater than 2, and the best finish is 3 or higher, or the people ID is 2 or less.

SELECT Best_Finish, Poker_Player_ID, Final_Table_Made, People_ID, Money_Rank FROM poker_player WHERE "Poker_Player_ID" > 4 OR "Best_Finish" >= 3.0 UNION SELECT Best_Finish, Poker_Player_ID, Final_Table_Made, People_ID, Money_Rank FROM poker_player WHERE "Final_Table_Made" != 26.0 AND "Poker_Player_ID" > 2 AND "Best_Finish" >= 3.0 OR "People_ID" <= 2


Question: Which driver IDs are less than 2 but not found in the school bus table with driver IDs less than 4?

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

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


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

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


Question: What is the sum of employee IDs from the evaluation table, excluding employee ID 2, and then subtract the sum of employee IDs from the hiring table where the employee ID is less than 6, the start date is 2008, or the employee is not full-time and the shop ID is greater than 5?

SELECT SUM(Employee_ID) FROM evaluation WHERE Employee_ID != "2" EXCEPT SELECT SUM(Employee_ID) FROM hiring WHERE "Employee_ID" < 6 OR Start_from = "2008" OR Is_full_time = "F" AND "Shop_ID" > 5


Question: Which aircraft IDs are not equal to 4, but are not present in the airport_aircraft table with an ID of 1?

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


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

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


Question: Which store IDs are not ranked 10 or are not named "Doaktown", and also which store IDs from the store_district table have an ID less than 4?

SELECT Store_ID FROM store WHERE "Ranking" <> 10 OR Store_Name != "Doaktown" UNION SELECT Store_ID FROM store_district WHERE "Store_ID" < 4


Question: What are the driver IDs, excluding driver ID 5, and also the driver IDs from school buses that are less than 10?

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


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

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


Question: What are the IDs of drivers, excluding driver 8, and the IDs of school buses, excluding bus 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 are the aircraft IDs that are greater than 2 and also present in the airport aircraft table, excluding aircraft ID 1?

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


Question: What are the aircraft IDs that appear in both the aircraft table (with IDs greater than or equal to 3) and the airport_aircraft table (with IDs greater than 1)?

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


Question: Which driver IDs are present in both the driver table (excluding driver ID 4) and the school bus table (with driver IDs no greater than 7)?

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


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

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


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

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


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

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


Question: What are the driver IDs that are less than 8 from the driver table, combined with the driver IDs that are less than or equal to 4 from the school bus table?

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


Question: What are the IDs of drivers who are not driver ID 4, and also the IDs of school bus drivers who are not driver 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: Which driver IDs are less than 3 in the driver table, combined with driver IDs from the school bus table that are not 7?

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


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

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


Question: Which shop IDs meet at least one of the following conditions: their start year is not 2011, they have full-time employees, or their employee ID is less than 3; or, their district is not "Finnair Stadium" and their manager's name is not "Job Dragtsma"?

SELECT Shop_ID FROM hiring WHERE Start_from <> "2011" OR Is_full_time = "T" OR "Employee_ID" < 3 UNION SELECT Shop_ID FROM shop WHERE District != "Finnair Stadium" AND Manager_name <> "Job Dragtsma"


Question: What are the ranks from the match results where the bronze value isn't 10, and the small silver value is greater than 9, or the club ID is 1, but not including ranks from players who have at least 5490 votes, aren't Design Coordinators, aren't Jim Maloway, and aren't ranked 3rd, or don't have Winnipeg Centre as a sponsor, or are male, or have a player ID greater than 14?

SELECT Rank FROM match_result WHERE "Bronze" <> 10 AND "Small_Silver" > 9 OR "Club_ID" = 1 EXCEPT SELECT Rank FROM player WHERE "Votes" >= 5490 AND Occupation != "Design Coordinator" AND Player_name != "Jim Maloway" AND Rank <> "3rd" OR Sponsor_name <> "Winnipeg Centre" OR Gender = "M" OR "Player_ID" > 14


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

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


Question: What is the smallest store ID that is not store ID 1 or not a City Mall, and what is the smallest store ID from a district that is not district ID 15?

SELECT MIN(Store_ID) FROM store WHERE "Store_ID" != 1 OR Type != "City Mall" UNION ALL SELECT MIN(Store_ID) FROM store_district WHERE "District_ID" <> 15


Question: Which driver IDs are less than 6 but not equal to 10, considering driver IDs from the driver table and school bus table?

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


Question: What are the aircraft IDs that are not 2 and also appear in the airport aircraft table with an ID less than 3?

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


Question: What are the sums of the dates, the minimum IDs, sums of velocities, flight numbers, and sums of altitudes for flights that meet these criteria: the company ID is less than 11, the velocity is less than 240, the altitude is 3650, the airport ID is 2, and the ID is greater than 8, or the pilot is Thompson and the flight number is not M2-F1 #73; but exclude flights where the ID is greater than 7 and the pilot is not Peterson and the company ID is less than 3, or the altitude is greater than 3650 and the flight number is not M2-F1 #64?

SUM(Date) MIN(id) SUM(Velocity) Vehicle_Flight_number SUM(Altitude)

SELECT SUM(Date), MIN(id), SUM(Velocity), Vehicle_Flight_number, SUM(Altitude) FROM flight WHERE "company_id" < 11 AND "Velocity" < 240.0 AND "Altitude" = 3650.0 AND "airport_id" = 2 AND "id" > 8 OR Pilot = "Thompson" AND Vehicle_Flight_number <> "M2-F1 #73" EXCEPT SELECT SUM(Date), MIN(id), SUM(Velocity), Vehicle_Flight_number, SUM(Altitude) FROM flight WHERE "id" > 7 AND Pilot != "Peterson" AND "company_id" < 3 OR "Altitude" > 3650.0 AND Vehicle_Flight_number != "M2-F1 #64"


Question: Which driver IDs are greater than 3, excluding those with ID 3, considering driver IDs from the 'driver' and 'school_bus' tables?

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


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

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


Question: Give me the shop ID, full-time status, and start date for hiring records where the shop ID is not 8, or the full-time status is not "T", or the start date is "2012" and the employee ID is 6 or greater. Also, include the shop ID, full-time status, and start date for hiring records where the start date is not "2012", the shop ID is not 1, and the full-time status is not "F".

SELECT Shop_ID, Is_full_time, Start_from FROM hiring WHERE "Shop_ID" != 8 OR Is_full_time != "T" OR Start_from = "2012" AND "Employee_ID" >= 6 UNION SELECT Shop_ID, Is_full_time, Start_from FROM hiring WHERE Start_from <> "2012" AND "Shop_ID" <> 1 AND Is_full_time != "F"


Question: Show me the last name, date of birth, staff ID, and date joined for staff members where the first name is Kaitlin, or the middle name is not Stephania, or the last name is not Turner, or the date left staff is not March 4, 2018, or the nickname is not nicholaus92, or the date of birth is June 3, 1995. Also, show the same information for staff members where the date of birth is not May 19, 2004, or the first name is not Titus and the staff address ID is less than or equal to 6.

SELECT last_name, date_of_birth, staff_id, date_joined_staff FROM Staff WHERE first_name = "Kaitlin" OR middle_name <> "Stephania" OR last_name <> "Turner" OR date_left_staff != "2018-03-04 17:13:53" OR nickname != "nicholaus92" OR date_of_birth = "1995-06-03 08:09:17" UNION ALL SELECT last_name, date_of_birth, staff_id, date_joined_staff FROM Staff WHERE date_of_birth != "2004-05-19 14:11:13" OR first_name <> "Titus" AND "staff_address_id" <= 6


Question: What are the IDs of albums with ID 319 or artist ID less than or equal to 22, combined with the IDs of employees who are not Sales Support Agents, don't have the email margaret@chinookcorp.com, are not from Canada, don't have postal code T3B 1Y7, don't have ID 6, report to someone with an ID less than or equal to 1, have the first name Nancy, are not from Lethbridge, are not from AB, or were not hired on August 14, 2002, and were born on January 9, 1968?

SELECT id FROM albums WHERE "id" = 319 OR "artist_id" <= 22 UNION ALL SELECT id FROM employees WHERE title <> "Sales Support Agent" AND email <> "margaret@chinookcorp.com" AND country <> "Canada" AND postal_code != "T3B 1Y7" AND "id" <> 6 AND "reports_to" <= 1.0 AND first_name = "Nancy" AND city != "Lethbridge" AND state <> "AB" OR hire_date <> "2002-08-14 00:00:00" AND birth_date = "1968-01-09 00:00:00"


Question: What are the aircraft IDs greater than 1 from the aircraft table, combined with the aircraft IDs greater than 2 from the airport_aircraft table?

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


Question: What are the club details (ID, description, location, and name) for "Bootup Baltimore" and also for any other clubs that are not located in "AKW", along with the details of the club with ID 4?

3
Play pen and paper games on campus.
HHH
Pen and Paper Gaming

4
A competitive tennis club.
AKW
Tennis Club

SELECT ClubID, ClubDesc, ClubLocation, ClubName FROM Club WHERE ClubName = "Bootup Baltimore" AND ClubDesc = "Venture capital fund for student business." UNION SELECT ClubID, ClubDesc, ClubLocation, ClubName FROM Club WHERE ClubName != "Bootup Baltimore" AND ClubLocation <> "AKW" OR "ClubID" = 4


Question: What are the driver IDs that are both greater than or equal to 8 and also not equal to 7, considering the driver IDs from the driver and school bus tables?

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


Question: What are the states, excluding Kansas, from the area code data, combined with the states from the votes data where the phone number isn't 5112677315 and the creation time isn't March 9, 2018, at 7:03:40 PM?

SELECT state FROM AREA_CODE_STATE WHERE state <> "KS" AND "area_code" <= 562 UNION SELECT state FROM VOTES WHERE "phone_number" <> 5112677315 AND created != "2018-03-09 19:03:40"


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

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


Question: What are the driver IDs that are equal to 8 in the driver table, but not equal to 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: Which driver IDs are greater than 8 but not present in the school bus table with IDs greater than or equal to 9?

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


Question: What are the driver IDs, excluding driver ID 1, that are present in both the driver and school bus tables, but with school bus driver IDs less than 7?

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


Question: What are the aircraft IDs that are greater than or equal to 4, excluding those with an ID of 2, considering only the aircraft table and the airport_aircraft table?

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


Question: What are the aircraft IDs that are not 2, but are not also aircraft IDs that are 5 or less, considering aircraft and airport aircraft information?

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


Question: What are the driver IDs that are both less than or equal to 6 and also not equal to 7, 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 <> 7


Question: Give me the age, state of birth, name, and head ID for people who are not 50 years old or whose name is Dudley Hart, excluding those born in Connecticut who have a head ID other than 1 or are 53 years old or older.

SELECT age, born_state, name, head_ID FROM head WHERE "age" != 50.0 OR name = "Dudley Hart" EXCEPT SELECT age, born_state, name, head_ID FROM head WHERE born_state = "Connecticut" AND "head_ID" <> 1 OR "age" >= 53.0


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

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


Question: What are the club IDs of clubs that are not named "Gefle IF" and are not in France and are not club ID 5, along with the club IDs from match results where Big_Silver is not 12 and the rank is 4 or less, or Gold is less than 5, or Bronze is 9 and Small_Silver is 4, or the club ID is 6?

SELECT Club_ID FROM club WHERE Club_name != "Gefle IF" AND Region <> "France" AND "Club_ID" != 5 UNION SELECT Club_ID FROM match_result WHERE "Big_Silver" <> 12 AND "Rank" <= 4 OR "Gold" < 5 OR "Bronze" = 9 AND "Small_Silver" = 4 OR "Club_ID" = 6


Question: What are the driver IDs that are less than or equal to 8, and also the driver IDs from school buses that are not 10?

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


Question: Which driver IDs are equal to 6 but not equal to 10, considering driver and school bus information?

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


Question: What are the titles and IDs of items that have an ID greater than or equal to 6 and are not item ID 4?

SELECT i_id, title FROM item WHERE "i_id" <> 4 INTERSECT SELECT i_id, title FROM item WHERE "i_id" >= 6


Question: Which driver IDs are less than 11, and also include driver ID 3, considering both driver and school bus information?

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


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

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


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

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


Question: What are the aircraft IDs that are present in the airport_aircraft table with ID 2 and also present in the aircraft table, excluding aircraft ID 4?

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


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

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


Question: What are the aircraft IDs that are not 4, and what are the aircraft IDs that are 5?

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


Question: What is the average branch ID and the total registration year for members with IDs less than 8, and also for all members except member ID 1?

SELECT AVG(Branch_ID), SUM(Register_Year) FROM membership_register_branch WHERE "Member_ID" < 8 UNION SELECT AVG(Branch_ID), SUM(Register_Year) FROM membership_register_branch WHERE "Member_ID" != 1


Question: What are the Comptroller and Year for parties that meet any of these conditions: the Party ID is less than 7 and the party is not Independence and the Attorney General is not Eliot Spitzer, or the Comptroller is Alan Hevesi, or the US Senate election was not (no election), or the year is not 2006; or the Party ID is not 3, or the Governor is Betsy McCaughey Ross and the US Senate election was Hillary Rodham Clinton and the year is after 2006, or the Attorney General is not Andrew Cuomo and the Lieutenant Governor is not David Paterson, or the Comptroller is not Alan Hevesi and the party is not Democratic?

SELECT Comptroller, Year FROM party WHERE "Party_ID" < 7 AND Party != "Independence" AND Attorney_General <> "Eliot Spitzer" OR Comptroller = "Alan Hevesi" OR US_Senate != "(no election)" OR "Year" <> 2006.0 UNION SELECT Comptroller, Year FROM party WHERE "Party_ID" <> 3 OR Governor = "Betsy McCaughey Ross" AND US_Senate = "Hillary Rodham Clinton" AND "Year" > 2006.0 OR Attorney_General <> "Andrew Cuomo" AND Lieutenant_Governor != "David Paterson" OR Comptroller != "Alan Hevesi" AND Party <> "Democratic"


Question: Which driver IDs are greater than or equal to 11 but not equal to 7 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: Which driver IDs are not equal to 4 and are in the driver table but not in the school bus table, excluding driver IDs equal to 7?

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


Question: What are the driver IDs less than 2 that are not driver IDs from school buses that are not equal to 7?

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


Question: What are the aircraft IDs that are not 5, and also the aircraft IDs that are 5 or greater, considering both the aircraft and airport_aircraft tables?

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


Question: What is the average PetID for pets where the student ID is not 1001, combined with the average PetID for pets that are not dogs or are young and lightweight?

SELECT AVG(PetID) FROM Has_Pet WHERE "StuID" <> 1001 UNION ALL SELECT AVG(PetID) FROM Pets WHERE PetType != "dog" OR "pet_age" < 2 AND "weight" < 13.4


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

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


Question: What is the average city population and the district ID, grouped by district name, where the city area is not 12 or the city population is 2793721, considering districts where the city area is 25, store ID is less than or equal to 4, the headquarters city is not Chiniot City and the district name is not Gujrat District, or the city population is less than or equal to 1526168?

SELECT AVG(T1.City_Population), T2.District_ID FROM district as T1 JOIN store_district as T2 ON T1.District_ID = T2.District_ID WHERE "City_Area" = 25.0 OR "Store_ID" <= 4 OR Headquartered_City <> "Chiniot City" AND District_name <> "Gujrat District" OR "City_Population" <= 1526168.0 GROUP BY District_name HAVING City_Area <> 12.0 OR City_Population = 2793721.0


Question: What are the IDs of drivers who are in both the driver and school bus tables, excluding driver ID 3 from the driver table and driver ID 7 from the school bus table?

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


Question: What are the document IDs and draft numbers for drafts in the circulation history where the draft number isn't 1 and the employee ID is less than 2 and the document ID is less than or equal to 1 or the copy number is 4? Also, what are the document IDs and draft numbers for drafts in the document drafts table where the document ID is 10, or the draft number is greater than 20, or the draft details are not "v"?

SELECT document_id, draft_number FROM Circulation_History WHERE "draft_number" != 1 AND "employee_id" < 2 AND "document_id" <= 1 OR "copy_number" = 4 UNION SELECT document_id, draft_number FROM Document_Drafts WHERE "document_id" = 10 OR "draft_number" > 20 OR draft_details != "v"


Question: What are the aircraft IDs of certificates where the employee ID is less than 242518965, excluding those aircraft IDs that have a flight arriving on 04/12/2005 05:03 with a distance of 1749, or going to Dallas, or where the aircraft ID is greater than 10, or the flight number is greater than 13, or originating from Los Angeles and costing less than 220.98?

SELECT aid FROM certificate WHERE "eid" < 242518965 EXCEPT SELECT aid FROM flight WHERE arrival_date = "04/12/2005 05:03" AND "distance" = 1749 OR destination = "Dallas" OR "aid" > 10 OR "flno" > 13 OR origin = "Los Angeles" AND "price" < 220.98


Question: What are the driver IDs greater than 7 that are also driver IDs equal to 10, considering driver and school bus information?

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


Question: What are the draft numbers that appear in both the Document Drafts table where the document ID is greater than 1 or the draft number is less than 17, and in the Draft Copies table where the copy number is not 4 or the document ID is less than or equal to 23?

SELECT draft_number FROM Document_Drafts WHERE "document_id" > 1 OR "draft_number" < 17 INTERSECT SELECT draft_number FROM Draft_Copies WHERE "copy_number" <> 4 OR "document_id" <= 23


Question: What are the driver IDs that are equal to 5 in the driver table, combined with the driver IDs that are not equal to 10 in the school bus table?

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


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

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


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

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


Question: Which driver IDs are less than or equal to 8 but not greater than or equal to 7, considering only driver IDs?

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


Question: What are the aircraft IDs that are not equal to 2 and are not present in the airport aircraft table with an aircraft ID of 1?

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


Question: What are the book IDs for book 4, combined with the book IDs from publications that don't have a publication date of August 2008, or have a publication ID of 3 or greater, or a book ID greater than 9, or a price of 6000000.0, or a publisher that isn't Thomson Reuters?

SELECT Book_ID FROM book WHERE "Book_ID" = 4 UNION ALL SELECT Book_ID FROM publication WHERE Publication_Date != "August 2008" OR "Publication_ID" >= 3 OR "Book_ID" > 9 OR "Price" = 6000000.0 OR Publisher <> "Thomson Reuters"


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

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


Question: What are the aircraft IDs that are less than 5 in the aircraft table or greater than 1 in the airport_aircraft table?

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


Question: What are the IDs of drivers who are in the driver table with an ID of 4 or greater, and also in the school bus table with an ID not equal to 4?

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


Question: What are the descriptions and names of clubs that are not located in AKW and are named "Hopkins Student Enterprises" and also not described as "A competitive tennis club.", combined with the descriptions and names of clubs located in AKW or with a club ID not equal to 3 or not described as "Refurbish computers; teach kids and adults about computer basics."?

Refurbish computers; teach kids and adults about computer basics.

Venture capital fund for student business.

Play pen and paper games on campus.
Pen and Paper Gaming

SELECT ClubDesc, ClubName FROM Club WHERE ClubLocation <> "AKW" AND "ClubID" <> 3 AND ClubName = "Hopkins Student Enterprises" AND ClubDesc <> "A competitive tennis club." UNION ALL SELECT ClubDesc, ClubName FROM Club WHERE ClubLocation = "AKW" OR "ClubID" != 3 OR ClubDesc != "Refurbish computers; teach kids and adults about computer basics."


Question: What are the driver IDs, excluding driver ID 4, from the driver table, combined with the driver IDs less than 4 from the school bus table?

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


Question: Which parties are associated with districts greater than 1 and representing 12.2 12B counties, or were first elected in or before 2002 and not on the Environmental Matters committee, or had Eliot Spitzer as Attorney General?

SELECT Party FROM election WHERE "District" > 1 AND Counties_Represented = "12.2 12B" OR "First_Elected" <= 2002.0 AND Committee <> "Environmental Matters" UNION SELECT Party FROM party WHERE Attorney_General = "Eliot Spitzer"


Question: What are the driver IDs that are present in both the driver table (excluding driver ID 10) and the school bus table (excluding driver ID 3)?

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


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

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


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

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


Question: What are the maximum People IDs, maximum birth dates, and heights for people born on April 17, 1987, with a height of at least 187, and also for people who don't have the name "Yevgeni Sivozhelez", or have a People ID less than or equal to 7, or are not Russian, or have a height not equal to 207 and were born on April 17, 1987?

SELECT MAX(People_ID), MAX(Birth_Date), Height FROM people WHERE Birth_Date = "April 17, 1987" AND "Height" >= 187.0 UNION ALL SELECT MAX(People_ID), MAX(Birth_Date), Height FROM people WHERE Name <> "Yevgeni Sivozhelez" OR "People_ID" <= 7 OR Nationality <> "Russia" OR "Height" <> 207.0 AND Birth_Date = "April 17, 1987"


Question: What are the role codes and descriptions for roles that are not "PT" and not "Editor", excluding those that are "PT" or "Proof Manager"?

SELECT role_code, role_description FROM Roles WHERE role_code != "PT" AND role_description <> "Editor" EXCEPT SELECT role_code, role_description FROM Roles WHERE role_code = "PT" OR role_description = "Proof Manager"


Question: What are the driver IDs greater than 10 from the driver table, combined with the driver IDs greater than 3 from the school bus table?

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


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

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


Question: What are the driver IDs, excluding driver ID 6, and also any driver IDs from school buses that are 9 or greater?

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


Question: What are the creation dates, states, contestant numbers, and vote IDs for votes where the phone number is less than or equal to 7148407040 and the state is not "NJ ", excluding any votes from New York, or where the contestant number is less than or equal to 2 and the creation date is not "2018-03-09 19:03:36" and the vote ID is less than 3?

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


Question: What are the aircraft IDs greater than 4, and also the aircraft IDs less than or equal to 3?

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


Question: Which driver IDs, up to 9, are in the driver table but not 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 are the aircraft IDs, excluding aircraft ID 4, and also the aircraft IDs from airport_aircraft, excluding aircraft ID 5?

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


Question: What are the continents, country IDs, and country names of all countries, excluding country ID 8, but not including any countries with country ID 3 or continent 4?

SELECT Continent, CountryId, CountryName FROM countries WHERE "CountryId" <> 8 EXCEPT SELECT Continent, CountryId, CountryName FROM countries WHERE "CountryId" = 3 OR "Continent" = 4


Question: Which driver IDs are greater than 12 in the driver table or are less than or equal to 10 in the school bus table?

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


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

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


Question: What are the IDs of albums that aren't titled "Chill: Brazil (Disc 2)" or don't have an artist ID of 142 and aren't ID 318, and also the IDs of media types that have an ID less than 4 or are named "AAC audio file"?

SELECT id FROM albums WHERE title <> "Chill: Brazil (Disc 2)" OR "artist_id" != 142 AND "id" <> 318 INTERSECT SELECT id FROM media_types WHERE "id" < 4 OR name = "AAC audio file"


Question: What are the IDs of aircraft that are either Mil Mi-26, or have a maximum disk loading of 3.7 lb/ft² (18 kg/m²) but not a total disk area of 4,900 ft² (460 m²), or have a maximum gross weight not equal to 50,000 lb (22,680 kg), and also have an aircraft ID of 2, or an ID not equal to 1, or an airport ID less than or equal to 9?

SELECT Aircraft_ID FROM aircraft WHERE Aircraft = "Mil Mi-26" OR Max_disk_Loading = "3.7 lb/ft² (18 kg/m²)" AND Total_disk_area <> "4,900 ft² (460 m²)" OR Max_Gross_Weight <> "50,000 lb (22,680 kg)" INTERSECT SELECT Aircraft_ID FROM airport_aircraft WHERE "Aircraft_ID" = 2 OR "ID" != 1 OR "Airport_ID" <= 9


Question: What are the aircraft IDs greater than or equal to 4, and what are the aircraft IDs less than or equal to 3?

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


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

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


Question: What are the aircraft IDs that are either 5 or not 2, considering both the aircraft and airport_aircraft tables?

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


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

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


Question: What are the driver IDs, excluding driver ID 8, and also the driver IDs less than 7, from the drivers and school buses tables?

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


Question: What are the aircraft IDs greater than 2, and also what are the aircraft IDs greater than 5, considering both the aircraft and airport_aircraft tables?

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


Question: Which shop IDs meet either of these conditions: the shop ID is at least 1 or the employee ID is greater than 1 and the employee is full-time, and also started in a year other than 2010?

SELECT Shop_ID FROM hiring WHERE "Shop_ID" >= 1 OR "Employee_ID" > 1 AND Is_full_time = "T" INTERSECT SELECT Shop_ID FROM hiring WHERE Start_from != "2010"


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

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


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

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


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

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


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

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


Question: What are the IDs of drivers, excluding driver 5, who are also assigned to a school bus, excluding driver 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 document IDs where the document ID is 1 or the draft number is less than 17 and the employee ID is 2, and also the document ID is 12 in the Documents Mailed table?

SELECT document_id FROM Circulation_History WHERE "document_id" = 1 OR "draft_number" < 17 AND "employee_id" = 2 UNION SELECT document_id FROM Documents_Mailed WHERE "document_id" = 12


Question: What are the driver IDs that are either less than or equal to 3, or greater than or equal to 10, considering driver IDs from both the driver and school bus tables?

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


Question: Which driver IDs are less than or equal to 10, excluding those with ID 10, considering only the driver table and the school bus table?

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


Question: Which department IDs have at least one name and either more than 4487 employees or the name is "Education", but not those that have a name other than "Transportation" or a budget less than or equal to 77.6 billion and a ranking of 6 or higher, and don't have exactly one creation record?

SELECT Department_ID, COUNT(Creation), COUNT(Name) FROM department WHERE "Num_Employees" > 4487.0 OR Name = "Education" GROUP BY Department_ID HAVING COUNT(Name) >= 1 EXCEPT SELECT Department_ID, COUNT(Creation), COUNT(Name) FROM department WHERE Name != "Transportation" OR "Budget_in_Billions" <= 77.6 AND "Ranking" >= 6 GROUP BY Department_ID HAVING COUNT(Creation) != 1


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

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


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

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


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

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


Question: What are the aircraft IDs that are present in both the aircraft table (excluding ID 5) and the airport_aircraft table (excluding ID 2)?

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


Question: Which driver IDs are greater than or equal to 3 but are not driver IDs that are not equal to 10?

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


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


Question: What are the role descriptions and codes for roles with the code "PT", including those that are not "Proof Manager"?

SELECT role_description, role_code FROM Roles WHERE role_description <> "Proof Manager" AND role_code = "PT" UNION SELECT role_description, role_code FROM Roles WHERE role_code = "PT"


Question: What are the aircraft IDs, excluding aircraft ID 2, and also aircraft ID 3?

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


Question: What are the aircraft IDs that are not 2 and are also present in the airport-aircraft table with IDs other than 5?

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


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

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


Question: What are the driver IDs, excluding driver ID 12, and also the driver IDs that are less than or equal to 3?

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


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

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


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

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


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

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


Question: Give me the phone number, contestant number, vote ID, creation date, and state for votes where the state is NY or the contestant number is at least 2, the phone number is less than 7182887233, and the vote ID is greater than 2. Also, include votes where the contestant number is not 5 or the vote ID is less than 1.

SELECT phone_number, contestant_number, vote_id, created, state FROM VOTES WHERE state = "NY" OR "contestant_number" >= 2 AND "phone_number" < 7182887233 AND "vote_id" > 2 UNION ALL SELECT phone_number, contestant_number, vote_id, created, state FROM VOTES WHERE "contestant_number" <> 5 OR "vote_id" < 1


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

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


Question: What are the IDs of aircraft, excluding aircraft ID 5, that are either in the aircraft table or associated with an airport in the airport_aircraft table?

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


Question: What are the document IDs from the Documents table where the shipping agent code is not US or the receipt number is 124, combined with the document IDs from the Draft_Copies table where the document ID is less than 23 and the copy number is not 15?

SELECT document_id FROM Documents WHERE shipping_agent_code != "US" OR receipt_number = "124" UNION ALL SELECT document_id FROM Draft_Copies WHERE "document_id" < 23 AND "copy_number" != 15


Question: What is the average gender and sum of rank for coaches where the rank is not 5, or the gender is not male, or the coach's name is not Jameson Tomas, or the coach ID is 3 or greater? Also, what is the average gender and sum of rank for players where the gender is male, or the sponsor name is not Winnipeg South, or the player's name is Judy Wasylycia-Leis and they live in Winnipeg, or the rank is 1st and the player ID is 10 and they have 5490 votes, or their occupation is student?

SELECT AVG(Gender), SUM(Rank) FROM coach WHERE "Rank" <> 5 OR Gender != "M" OR Coach_name <> "Jameson Tomas" OR "Coach_ID" >= 3 UNION SELECT AVG(Gender), SUM(Rank) FROM player WHERE Gender = "M" OR Sponsor_name <> "Winnipeg South" OR Player_name = "Judy Wasylycia-Leis" AND Residence = "Winnipeg" OR Rank = "1st" AND "Player_ID" = 10 AND "Votes" = 5490 OR Occupation = "Student"


Question: Which driver IDs are not equal to 2 and are not found in the school bus table with a driver ID of 9?

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


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

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


Question: What are the descriptions of other property features where the property ID is 6, or the feature ID is not 2, or the description is "doloribus", and also where the feature ID is not 2?

SELECT property_feature_description FROM Other_Property_Features WHERE "property_id" = 6 OR "feature_id" <> 2 OR property_feature_description = "doloribus" INTERSECT SELECT property_feature_description FROM Other_Property_Features WHERE "feature_id" != 2


Question: Which driver IDs are equal to 1 but not equal to 4 in the school bus table?

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


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

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


Question: What are the driver IDs that are present in both the driver and school bus tables, excluding driver ID 4 from the driver table and only including driver IDs greater 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: What are the aircraft IDs that are less than 2 in the aircraft table, but not greater than 2 in the airport_aircraft table?

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


Question: What is the maximum property type code, excluding "Other", from the Properties table where either the property type code is not "Other", or oth_feature_2 is "None", and apt_feature_1 is not "enim", or shp_feature_3 is not "None", and also the maximum property type code, excluding "Other", from the Ref_Property_Types table?

SELECT MAX(property_type_code) FROM Properties WHERE property_type_code <> "Other" OR oth_feature_2 = "None" AND apt_feature_1 <> "enim" OR shp_feature_3 != "None" INTERSECT SELECT MAX(property_type_code) FROM Ref_Property_Types WHERE property_type_code != "Other"


Question: Which driver IDs are both less than or equal to 3 in the driver table and less than or equal to 7 in the school bus table?

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


Question: Which driver IDs are either less than or equal to 11 from the driver table, or greater than 4 from the school bus table?

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


Question: What are the aircraft IDs that are either less than or equal to 5, or 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: What are the shipping agent codes that are not named "Ship" or have a description other than "k", and also are not named "Ship" or have a code other than "FE"?

SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name != "Ship" OR shipping_agent_description <> "k" INTERSECT SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name <> "Ship" OR shipping_agent_code <> "FE"


Question: What is the maximum airport ID and the number of transit passengers for each airport?

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


Question: What are the aircraft IDs, excluding aircraft ID 4, from the aircraft table and also the aircraft IDs less than 1 from the airport_aircraft table?

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


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

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


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

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


Question: What are the names of donors and their school IDs from the endowment table where the amount is 9.05 or the school ID is greater than 1, and also where the amount is 9.73 or the endowment ID is 6 or higher?

SELECT donator_name, School_id FROM endowment WHERE "amount" = 9.05 OR "School_id" > 1 UNION ALL SELECT donator_name, School_id FROM endowment WHERE "amount" = 9.73 OR "endowment_id" >= 6


Question: What are the aircraft IDs that are less than or equal to 1 and are not present in the airport aircraft table with an ID not equal to 1?

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


Question: What are all the different role codes, excluding "MG", from the Employees table, combined with the role codes from the Roles table where the description isn't "Proof Manager"?

SELECT role_code FROM Employees WHERE role_code <> "MG" UNION ALL SELECT role_code FROM Roles WHERE role_description <> "Proof Manager"


Question: What are the aircraft IDs that are not 2, and also the aircraft IDs greater than 5, considering both the aircraft and airport_aircraft tables?

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


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

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


Question: What are the car models that are not from make ID 94 or are not "amc" or are "oldsmobile cutlass ls", and also the models that are "toyota" and have a maker ID less than 4?

SELECT Model FROM car_names WHERE "MakeId" != 94 OR Model != "amc" OR Make = "oldsmobile cutlass ls" UNION SELECT Model FROM model_list WHERE "Maker" < 4 AND Model = "toyota"


Question: What are the IDs of albums with an ID of 185 or higher, excluding the album titled "Alcohol Fueled Brewtality Live! [Disc 1]", and also the IDs of media types that are "AAC audio file" or have an ID greater than 1?

SELECT id FROM albums WHERE "id" >= 185 AND title != "Alcohol Fueled Brewtality Live! [Disc 1]" UNION ALL SELECT id FROM media_types WHERE name = "AAC audio file" OR "id" > 1


Question: Which driver IDs are greater than 11, and also include 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: Which driver IDs are present in both the driver table (excluding driver ID 3) and the school bus table (with driver ID 10)?

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


Question: Which vehicle IDs are used in lessons that are not lesson ID 9 and have a vehicle ID less than 2, or are completed, or have a staff ID less than 8, but are not used in trucks with vehicle IDs greater than 1?

SELECT vehicle_id FROM Lessons WHERE "lesson_id" != 9 AND "vehicle_id" < 2 OR lesson_status_code = "Completed" OR "staff_id" < 8 EXCEPT SELECT vehicle_id FROM Vehicles WHERE vehicle_details = "Truck" AND "vehicle_id" > 1


Question: What are the ranks from the match results where "Big_Silver" is not 6 or "Bronze" is not 10 and "Gold" is greater than 13, combined with the ranks from players who are ranked "3rd" and have 2353 votes, or whose occupation isn't "Student", or whose sponsor name isn't "Kildonan—St. Paul" and don't live in "Brandon" and are male?

SELECT Rank FROM match_result WHERE "Big_Silver" <> 6 OR "Bronze" <> 10 AND "Gold" > 13 UNION ALL SELECT Rank FROM player WHERE Rank = "3rd" AND "Votes" = 2353 OR Occupation <> "Student" OR Sponsor_name != "Kildonan—St. Paul" AND Residence <> "Brandon" AND Gender = "M"


Question: What are the aircraft IDs that are not 2 and are in the aircraft table, but not in the airport_aircraft table with IDs less than 1?

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


Question: Which aircraft IDs are not equal to 5, but are not present in the airport_aircraft table with an ID of 2?

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


Question: What are the IDs of male students in Baltimore or students whose last name isn't Pang or student 1034, who also have allergies other than cats?

SELECT StuID FROM Has_Allergy WHERE Allergy <> "Cat" INTERSECT SELECT StuID FROM Student WHERE Sex = "M" AND city_code = "BAL" OR LName <> "Pang" OR "StuID" = 1034


Question: What are the names of the contestants whose number is 2 or less, combined with the names of all contestants except contestant number 10?

SELECT contestant_name FROM CONTESTANTS WHERE "contestant_number" <= 2 UNION ALL SELECT contestant_name FROM CONTESTANTS WHERE "contestant_number" != 10


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


Question: What are the aircraft IDs that are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 2 from the first table and aircraft ID 5 from the second?

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


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

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


Question: What are the driver IDs that are either 4 or less than or equal to 7?

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: Which driver IDs are either 12 or greater than 10?

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


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

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


Question: What are the aircraft IDs that are both less than or equal to 5 and also equal to 3?

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


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

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


Question: What are the IDs of people who are at least 193cm tall, but not player IDs greater than 7?

SELECT People_ID FROM people WHERE "Height" >= 193.0 EXCEPT SELECT People_ID FROM poker_player WHERE "People_ID" > 7


Question: What is the minimum number of transit passengers and the corresponding aircraft ID for each airport?

SELECT MIN(T1.Transit_Passengers), T2.ID FROM airport as T1 JOIN airport_aircraft as T2 ON T1.Airport_ID = T2.Airport_ID


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

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


Question: What are the driver IDs that are not 1 and are present in both the driver and school bus tables, with the driver ID being 4 or greater in the school bus table?

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


Question: What are the names of feature types that have the code "Amenity" but are not "Securiyt, eg Burglar Alarm.", and also either do not have the code "Amenity" or are "Amenity, eg Pool."?

SELECT feature_type_name FROM Ref_Feature_Types WHERE feature_type_code = "Amenity" AND feature_type_name != "Securiyt, eg Burglar Alarm." INTERSECT SELECT feature_type_name FROM Ref_Feature_Types WHERE feature_type_code != "Amenity" OR feature_type_name = "Amenity, eg Pool."


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

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


Question: What are the driver IDs that are at least 4, or the driver IDs that are at most 7, considering both drivers and school buses?

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


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

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


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

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