Question: Are there any driver IDs that are 6 in the driver table but not among the driver IDs less than 9 in the school bus table?

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


Question: What are the driver IDs that are in both the driver and school bus lists and are between 9 and 12?

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


Question: Show me the car maker ID and year for each cylinder count, but only for groups of cars that meet a specific set of complex criteria.

SELECT T1.Id, T2.Year FROM car_makers as T1 JOIN cars_data as T2 ON T1.Id == T2.Id GROUP BY Cylinders HAVING FullName <> "Subaru" AND Maker <> "renault" AND Weight >= 3459 OR Accelerate <> 12.2 OR Cylinders = 8 AND Edispl <> 351.0 OR Horsepower <> "180" AND MPG = "13" AND Year >= 1974 AND Country <> "3"


Question: Tell me the major, age, average sex, first name, advisor, and city code for students who are not named Thornton and also meet at least one of these conditions: they are either not advised by advisor 8722 and not from city LON, or their first name is William, or they are under 20, have last name Davis, and their major is not 600.

Major Age AVG(Sex) Fname Advisor city_code

SELECT Major, Age, AVG(Sex), Fname, Advisor, city_code FROM Student WHERE "Advisor" <> 8722 AND city_code <> "LON" OR Fname = "William" OR "Major" != 600 AND LName = "Davis" AND "Age" < 20 INTERSECT SELECT Major, Age, AVG(Sex), Fname, Advisor, city_code FROM Student WHERE LName != "Thornton"


Question: What are the driver IDs that are 3 or greater, excluding driver ID 4 if they are school bus drivers?

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


Question: What are the driver IDs, specifically those not equal to 4 from the driver table and those greater than or equal to 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: What driver IDs are either not 6 in the driver table, or greater than 4 in the school_bus table?

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


Question: What are the driver IDs that are both greater than 6 and no more than 10?

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


Question: Which Aircraft IDs are greater than 4 in the aircraft table and also greater than 1 in the airport_aircraft table?

SELECT Aircraft_ID FROM aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 4 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID > 1


Question: What are the car IDs that meet the criteria from both the car makers and cars data tables? For car makers, consider cars that are 'honda' but not 'Nissan Motors', or have an ID of 23 or less, or are not from country '8'. For cars data, consider cars that are not weight 2774, not ID 197, and not 6 cylinders, or have acceleration less than 12.0 and engine displacement greater than 91.0, or were made in 1980 or earlier and do not have 75 horsepower, or do not have 26.5 MPG?

SELECT Id FROM car_makers WHERE Maker = "honda" AND FullName <> "Nissan Motors" OR "Id" <= 23 OR Country <> "8" INTERSECT SELECT Id FROM cars_data WHERE "Weight" <> 2774 AND "Id" <> 197 AND "Cylinders" != 6 OR "Accelerate" < 12.0 AND "Edispl" > 91.0 OR "Year" <= 1980 AND Horsepower != "75" OR MPG != "26.5"


Question: What driver IDs are both greater than 1 and less than 9, and are listed in both the driver and school bus records?

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


Question: What are the counts of each sex, city codes, sums of last names, first names, maximum ages, majors, student IDs, and advisors for students who fit certain criteria about their age, city, name, major, advisor, and gender, but not if they also fit another criteria related to their student ID and advisor?

COUNT(Sex) city_code SUM(LName) Fname MAX(Age) Major StuID Advisor

SELECT COUNT(Sex), city_code, SUM(LName), Fname, MAX(Age), Major, StuID, Advisor FROM Student WHERE "Age" != 17 AND city_code != "CHI" OR LName != "Brown" AND "Major" < 520 AND "Advisor" >= 1148 OR Sex != "F" AND "StuID" != 1006 EXCEPT SELECT COUNT(Sex), city_code, SUM(LName), Fname, MAX(Age), Major, StuID, Advisor FROM Student WHERE "StuID" <> 1014 AND "Advisor" >= 7134


Question: Could you list the parties and lieutenant governors for all years before 2006, as well as for 2006 when the lieutenant governor was not Dennis Mehiel and the party ID was 1?

SELECT Party, Lieutenant_Governor FROM party WHERE "Year" < 2006.0 UNION SELECT Party, Lieutenant_Governor FROM party WHERE "Year" = 2006.0 AND Lieutenant_Governor != "Dennis Mehiel" AND "Party_ID" = 1


Question: Which driver IDs are for drivers with an ID of 2 or less, but not for school bus drivers with an ID 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 are the driver IDs that are both 11 or less and also 4 or greater?

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 driver IDs, excluding driver 2 from the driver list and driver 3 from the school bus driver list?

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


Question: Which Driver IDs are 2 or less in the driver table, or 3 in the school_bus table?

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


Question: Which driver IDs, other than 4, are drivers but not school bus drivers, considering only school bus drivers who are not ID 9?

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


Question: What are the driver IDs that are not 8 from the driver table, and also the driver IDs that are 9 or less 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 <= 9


Question: Is driver ID 6 listed as a driver but not as a school bus driver?

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


Question: What is the total company ID and average velocity for flights that are either piloted by Thompson and not flight 'M2-F1 #1', or had an altitude other than 3650.0 on September 3, 1963, or are flight 'M2-F1 #61', or are not on March 28, 1966 with a velocity other than 240.0, or are not piloted by Peterson?

SELECT SUM(company_id), AVG(Velocity) FROM flight WHERE Pilot = "Thompson" AND Vehicle_Flight_number <> "M2-F1 #1" OR "Altitude" <> 3650.0 AND Date = "September 3, 1963" UNION ALL SELECT SUM(company_id), AVG(Velocity) FROM flight WHERE Vehicle_Flight_number = "M2-F1 #61" OR Date <> "March 28, 1966" AND "Velocity" <> 240.0 OR Pilot != "Peterson"


Question: List the aircraft IDs that are 3 or more, or for flights that have a distance less than 1749, or a price of 425.98 or less and an arrival date not '2005-12-04 05:03', or a destination other than 'New York' and origin 'Los Angeles' and flight number greater than 99, or a departure date not '2005-12-04 07:03'.

SELECT aid FROM aircraft WHERE "aid" >= 3 UNION SELECT aid FROM flight WHERE "distance" < 1749 OR "price" <= 425.98 AND arrival_date <> "04/12/2005 05:03" OR destination != "New York" AND origin = "Los Angeles" AND "flno" > 99 OR departure_date != "04/12/2005 07:03"


Question: List all flight details including departure date, destination, price, flight number, airline ID, distance, origin, and arrival date for flights that are either from Los Angeles, departing on '04/12/2005 08:32', or priced at 375.23 or more, as well as flights that have an airline ID of 1 or less and arrive at a time other than '04/12/2005 03:55', or depart at a time other than '04/12/2005 09:15', or have a price of 375.23 or less and are not going to Chicago, or are not originating from Chicago.

departure_date destination price flno aid distance origin arrival_date

SELECT departure_date, destination, price, flno, aid, distance, origin, arrival_date FROM flight WHERE origin = "Los Angeles" OR departure_date = "04/12/2005 08:32" OR "price" >= 375.23 UNION ALL SELECT departure_date, destination, price, flno, aid, distance, origin, arrival_date FROM flight WHERE "aid" <= 1 AND arrival_date <> "04/12/2005 03:55" OR departure_date <> "04/12/2005 09:15" OR "price" <= 375.23 AND destination != "Chicago" OR origin <> "Chicago"


Question: Which driver IDs are both in the driver list, excluding driver 12, and in the school bus list, excluding driver 7?

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


Question: What driver IDs are greater than 10 in the driver table, or less than 9 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: Which Aircraft IDs are in both the aircraft and airport aircraft lists, and are also greater than or equal to 4 in the aircraft list and not equal to 2 in the airport aircraft list?

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 albums with IDs less than 13 and media types with IDs less than or equal to 2?

SELECT id FROM albums WHERE "id" < 13 UNION SELECT id FROM media_types WHERE "id" <= 2


Question: What are the minimum document type codes, specifically: one excluding "Hard Drive", and another for those described as "f" and not "CD"?

SELECT MIN(document_type_code) FROM Ref_Document_Types WHERE document_type_code != "Hard Drive" UNION ALL SELECT MIN(document_type_code) FROM Ref_Document_Types WHERE document_type_description = "f" AND document_type_code <> "CD"


Question: What are the driver IDs that are number 11 or are not number 7 in the school bus list?

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


Question: Which driver IDs are for drivers who are not also school bus drivers? Exclude driver ID 2 from the drivers, and only consider school bus drivers with IDs up to 9.

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


Question: What driver IDs are common to both drivers with IDs greater than 2 and school bus drivers with ID 7?

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


Question: What are the employee IDs for employees who are not from Bristol, as well as employee IDs from hiring records where either the shop ID is 1 or more and the start year is 2010, or the employee is not full-time?

SELECT Employee_ID FROM employee WHERE City <> "Bristol" UNION ALL SELECT Employee_ID FROM hiring WHERE "Shop_ID" >= 1 AND Start_from = "2010" OR Is_full_time != "T"


Question: What is the highest car ID and its MPG for cars that are either from 1974 onwards with 150 horsepower and not 38 MPG, or have an engine displacement greater than 140, or accelerate in 16 seconds, or are not a Citroen, or are made by Citroen?

SELECT MAX(T1.Id), T2.MPG FROM car_makers as T1 JOIN cars_data as T2 ON T1.Id = T2.Id WHERE "Year" >= 1974 AND Horsepower = "150" AND MPG <> "38" OR "Edispl" > 140.0 OR "Accelerate" = 16.0 OR FullName <> "Citroen" OR Maker = "citroen"


Question: Which driver IDs are at least 2 in the driver table but are not in the school bus table, unless they are driver ID 7?

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


Question: What are the details and IDs of vans with a vehicle ID less than 2?

SELECT vehicle_details, vehicle_id FROM Vehicles WHERE "vehicle_id" <> 2 AND vehicle_details = "Van" INTERSECT SELECT vehicle_details, vehicle_id FROM Vehicles WHERE "vehicle_id" <= 2


Question: What are the working years and driver IDs for school buses with a school ID of 1 or higher that are not full-time, except for those with a driver ID less than 10 and working years of 2 or less?

SELECT Years_Working, Driver_ID FROM school_bus WHERE "School_ID" >= 1 AND If_full_time <> "T" EXCEPT SELECT Years_Working, Driver_ID FROM school_bus WHERE "Driver_ID" < 10 AND "Years_Working" <= 2


Question: Give me the advisor and student ID for students who either have a major code of 540 or less, or a student ID of 1031 or more, or who are not 20 years old, or have a major code other than 600, or have an advisor other than 5718, or are named Lisa and from PIT, or are not male.

SELECT Advisor, StuID FROM Student WHERE "Major" <= 540 OR "StuID" >= 1031 UNION SELECT Advisor, StuID FROM Student WHERE "Age" <> 20 OR "Major" <> 600 OR "Advisor" != 5718 OR Fname = "Lisa" AND city_code = "PIT" OR Sex != "M"


Question: Which customer IDs are for payments made on February 19, 2018 at 09:06:29, excluding payments of $6782.84, or for customers who either don't have the phone number '192-395-2411' or have mobile number '081-097-3684' and an email address other than 'asha.kilback@example.org'?

SELECT customer_id FROM Customer_Payments WHERE datetime_payment = "2018-02-19 09:06:29" AND "amount_payment" <> 6782.84 UNION SELECT customer_id FROM Customers WHERE phone_number != "192-395-2411" OR cell_mobile_phone_number = "081-097-3684" AND email_address <> "asha.kilback@example.org"


Question: What are the aircraft IDs that are in both the aircraft table (excluding ID 3) and the airport aircraft table (including only IDs 1 and 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 driver IDs are ID 1 from the driver table, or IDs 1, 2, or 3 from the school bus table?

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


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

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


Question: What are the item IDs and their ranks for items with a rank less than 3, where the associated review has a reviewer ID of 7 or less?

SELECT T1.i_id, T2.rank FROM item as T1 JOIN review as T2 ON T1.i_id == T2.i_id GROUP BY rank HAVING rank < 3 AND a_id <= 7


Question: What are all District IDs from the 'district' table for districts that either have a City Population of 530438, or have a City Area not equal to 10, a District ID of 2 or less, and are not headquartered in "Jhelum City"? Also, include all District IDs from the 'store_district' table for stores that have a Store ID of 1 or less and a District ID less than 11.

SELECT District_ID FROM district WHERE "City_Population" = 530438.0 OR "City_Area" <> 10.0 AND "District_ID" <= 2 AND Headquartered_City != "Jhelum City" UNION ALL SELECT District_ID FROM store_district WHERE "Store_ID" <= 1 AND "District_ID" < 11


Question: Is Aircraft ID 1 in both the aircraft and airport_aircraft tables, given we ignore Aircraft ID 5 in the airport_aircraft table?

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


Question: What aircraft types, along with their minimum ID and maximum distance, meet one set of conditions but not another?

SELECT MIN(aid), MAX(distance), name FROM aircraft WHERE "aid" >= 5 AND name != "Airbus A340-300" AND "distance" != 4103 GROUP BY name HAVING MIN(aid) >= 13 EXCEPT SELECT MIN(aid), MAX(distance), name FROM aircraft WHERE "aid" >= 5 AND "distance" < 7120 OR name != "Boeing 767-400ER" GROUP BY name HAVING MAX(distance) = 3383


Question: For each airport ICAO code, what are the minimum airport ID and company ID, considering only the airports and flights that satisfy a very specific and complex set of criteria?

SELECT MIN(T1.id), T2.company_id FROM airport as T1 JOIN flight as T2 ON T1.id = T2.id WHERE IATA <> "BLL" OR Date = "January 29, 1964" OR "Altitude" <= 3650.0 AND ICAO <> "EBBR" AND "airport_id" > 2 AND name = "Billund Airport" GROUP BY ICAO HAVING City = "Akureyri" AND MIN(company_id) < 2 AND name <> "Ted Stevens Airport" AND IATA = "BCN" OR Vehicle_Flight_number = "M2-F1 #61" AND SUM(Velocity) >= 240.0 OR airport_id <> 3 OR Pilot = "Thompson" AND MIN(Altitude) <= 3650.0 AND Country = "Netherlands" OR ICAO = "LEBL"


Question: What are the head IDs for people who are not named 'Billy Mayfair' or have an ID of 9, excluding those who are non-temporary managers with an ID greater than 6?

SELECT head_ID FROM head WHERE name != "Billy Mayfair" OR "head_ID" = 9 EXCEPT SELECT head_ID FROM management WHERE temporary_acting = "No" AND "head_ID" > 6


Question: What are the Aircraft IDs that are not 1 from the aircraft table, and those that are 3 or less 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 <= 3


Question: Which Aircraft IDs are in the aircraft table, except for 5, and are not among the Aircraft IDs that are 1 or less in the airport_aircraft table?

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


Question: What are the store IDs that are for stores with area size 21.73 and also appear in store districts with an ID over 3?

SELECT Store_ID FROM store WHERE "Area_size" = 21.73 INTERSECT SELECT Store_ID FROM store_district WHERE "Store_ID" > 3


Question: What are the budgeted amount, year, total budget percentage invested, total budget percentage budgeted, and school ID for budget records that satisfy either (school ID is 4 or less, percentage invested is less than 2.2, budgeted amount is 6803 or more, and invested amount is greater than 95542) or percentage budgeted is 2.0 or less or year is 2001 or later or percentage invested is 2.2 or more or budgeted amount is not 3666 and invested amount is not 8335?

SELECT Budgeted, Year, total_budget_percent_invested, total_budget_percent_budgeted, School_id FROM budget WHERE "School_id" <= 4 AND "total_budget_percent_invested" < 2.2 AND "Budgeted" >= 6803 AND "Invested" > 95542 OR "total_budget_percent_budgeted" <= 2.0 UNION ALL SELECT Budgeted, Year, total_budget_percent_invested, total_budget_percent_budgeted, School_id FROM budget WHERE "Year" >= 2001 OR "total_budget_percent_invested" >= 2.2 OR "Budgeted" <> 3666 AND "Invested" != 8335


Question: What driver IDs are in both the list of drivers, excluding driver ID 12, and the list of school bus drivers, excluding driver ID 7?

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


Question: What aircraft IDs are there that are 1 or higher in the aircraft table, or 3 or higher in the airport aircraft table?

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


Question: What continents are listed for continent IDs of 3 or greater, along with continents that are not continent number 4, or not named 'uk', or have a country ID less than 6?

SELECT Continent FROM continents WHERE "ContId" >= 3 UNION ALL SELECT Continent FROM countries WHERE "Continent" != 4 OR CountryName != "uk" OR "CountryId" < 6


Question: For each airport, what is the largest aircraft ID that is associated with it?

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


Question: What document IDs are common to both document drafts with a document ID greater than 12 or a draft number greater than 20, and documents that are either of type 'Hard Drive' and not receipt number '93', or have a document ID of 2 or more, or were received on '1983-09-26 09:32:56' and are not 'done', not shipped by 'UP', and have other details not 'x'?

SELECT document_id FROM Document_Drafts WHERE "document_id" > 12 OR "draft_number" > 20 INTERSECT SELECT document_id FROM Documents WHERE document_type_code = "Hard Drive" AND receipt_number != "93" OR "document_id" >= 2 OR receipt_date = "1983-09-26 09:32:56" AND document_status_code <> "done" AND shipping_agent_code != "UP" AND other_details <> "x"


Question: What aircraft IDs greater than 2 are in the aircraft table but not in the airport_aircraft table, disregarding aircraft ID 1 in the airport_aircraft table?

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


Question: What aircraft IDs are either less than 4, or specifically ID 1, 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 = 1


Question: What are the driver IDs that are not 4 from the driver table, or are greater than 3 from the school bus table?

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


Question: What are the employee IDs for employees who either have a certificate ID other than 552455318, or a certificate aid less than 12, or are named 'Eric Cooper' and have an ID other than 574489457, or have a salary greater than 212156?

SELECT eid FROM certificate WHERE "eid" != 552455318 OR "aid" < 12 UNION SELECT eid FROM employee WHERE "eid" <> 574489457 AND name = "Eric Cooper" OR "salary" > 212156


Question: Which Driver IDs are either greater than 9 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 > 9 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 4


Question: Which driver IDs are greater than 6, and are not among the driver IDs less than 7 in the school bus list?

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


Question: Which aircraft ID is 5, but only if aircraft ID 1 is not an airport aircraft?

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


Question: Which Driver IDs are greater than 2 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 > 2 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


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


Question: What are the driver IDs that are in the driver list, excluding driver ID 8, but are not in the school bus driver list for IDs 7 or higher?

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 driver IDs that are either 6 for drivers or 4 for school buses?

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


Question: What driver IDs are 7 or less, or are not 9 in the school bus records?

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


Question: What driver IDs are in the driver list, except for ID 4, and also not in the school bus list if they are less than 3?

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


Question: What are the phone numbers and the corresponding sum of area codes, excluding records created on "2018-03-09 19:03:21"?

SELECT SUM(T1.area_code), T2.phone_number FROM AREA_CODE_STATE as T1 JOIN VOTES as T2 ON T1.state = T2.state WHERE created <> "2018-03-09 19:03:21"


Question: What driver IDs are both not equal to 6 and also greater than or equal to 4?

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 driver IDs are ID 6 from the driver list, or IDs less than 3 from the school bus list?

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


Question: What driver IDs are 2 or less, but are not among those greater than 7 in the school bus list?

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


Question: What Aircraft IDs are in both the aircraft table (excluding ID 5) and the airport_aircraft table (including only IDs up 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: What driver IDs are greater than 7 and are not school bus driver IDs, if we ignore school bus driver ID 3?

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


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

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


Question: What is the sum of Model, along with Maker and ModelId, for models that are not 'audi', have a ModelId other than 31, and a Maker other than 5, and also for models that are not 'dodge' and either have a Maker less than 5 or a ModelId is 12 or less?

SELECT SUM(Model), Maker, ModelId FROM model_list WHERE Model != "audi" AND "ModelId" <> 31 AND "Maker" <> 5 UNION ALL SELECT SUM(Model), Maker, ModelId FROM model_list WHERE Model <> "dodge" AND "Maker" < 5 OR "ModelId" <= 12


Question: Which driver IDs are drivers other than driver 3 and also school bus drivers other than driver 7?

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


Question: What driver IDs are less than 3 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 < 3 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 4


Question: What are the Aircraft IDs that are greater than 1 in the aircraft table or less than 2 in the airport aircraft table?

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


Question: What are the unique Aircraft IDs that are at most 2 from the aircraft table, or at least 5 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 >= 5


Question: What driver IDs are 1 or greater and are not also IDs of school bus drivers?

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


Question: What are the item IDs, user IDs, and ratings for reviews that are both either not from user 2 or for item 2, and also either rated 5 or less by user 1 or for item 3 or less?

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


Question: What copy numbers, document IDs, and draft numbers are found in both the circulation history for documents other than document ID 2, and in the draft copies where the copy number is 4 or less, or the document ID is 20 or greater?

SELECT copy_number, document_id, draft_number FROM Circulation_History WHERE "document_id" <> 2 INTERSECT SELECT copy_number, document_id, draft_number FROM Draft_Copies WHERE "copy_number" <= 4 OR "document_id" >= 20


Question: What driver IDs are found in drivers (excluding ID 9) or school buses (excluding ID 4)?

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


Question: What driver IDs are greater than 2 and not 10, and are in both driver and school bus lists?

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: For districts with a city area less than 10 or equal to 147, could you list the headquartered city, district ID, and the counts of district names and city areas?

SELECT Headquartered_City, COUNT(District_name), District_ID, COUNT(City_Area) FROM district WHERE "City_Area" < 10.0 UNION ALL SELECT Headquartered_City, COUNT(District_name), District_ID, COUNT(City_Area) FROM district WHERE "City_Area" = 147.0


Question: What Driver IDs are either 10 or less from the driver list or 3 or more from the school bus list?

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 aircraft IDs, along with the number of names and total distance for each, for aircraft that either have a total distance less than 2128 and at least one name, or have more than one name?

SELECT aid, COUNT(name), SUM(distance) FROM aircraft GROUP BY aid HAVING SUM(distance) < 2128 AND COUNT(name) >= 1 UNION SELECT aid, COUNT(name), SUM(distance) FROM aircraft GROUP BY aid HAVING COUNT(name) > 1


Question: What driver IDs are common to both drivers with IDs greater than or equal to 1 and school bus drivers with IDs greater than or equal to 10?

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


Question: What driver IDs are in the driver table, except for 8, or in the school bus table, except for 4?

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 driver IDs are in the driver table, excluding ID 9, but not driver ID 10 in the school_bus table?

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


Question: What driver IDs are either 4 or greater from the drivers, or not 10 from the 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 != 10


Question: What driver IDs are in the driver list, are not 12, and are not among the driver IDs in the school bus list that are greater than 4?

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


Question: What average allergy level and allergy type are found in common between allergies that are not 'Dog', and allergies that are not 'Ragweed' and are not of 'animal' type?

SELECT AVG(Allergy), AllergyType FROM Allergy_Type WHERE Allergy <> "Dog" INTERSECT SELECT AVG(Allergy), AllergyType FROM Allergy_Type WHERE AllergyType != "animal" AND Allergy <> "Ragweed"


Question: What driver IDs are common to drivers with IDs of 5 or less and school bus drivers with ID 3?

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


Question: What driver IDs are on the driver list, excluding driver ID 8, but are not on the school bus driver list, excluding driver ID 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 that are greater than 11 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 > 11 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 4


Question: What are the Driver IDs, excluding ID 8 for drivers and ID 10 for school buses?

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


Question: What are the Shop IDs of shops that either started hiring in a year other than 2012 or have fewer than 4 employees, or are not in 'Jakobstads Centralplan', have 1600 or more products, or are named 'FF Jaro'?

SELECT Shop_ID FROM hiring WHERE Start_from != "2012" OR "Employee_ID" < 4 UNION SELECT Shop_ID FROM shop WHERE District != "Jakobstads Centralplan" OR "Number_products" >= 1600 OR Name = "FF Jaro"


Question: What are the driver IDs that are at least 7 from the driver list, or are any driver ID except 4 from the school bus list?

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


Question: What driver IDs are 6 or greater in the driver table but not also greater than 4 in the school bus table?

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


Question: What Driver IDs are either 8 or greater in the driver table, or not 3 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 != 3


Question: What are the Driver IDs that are 1 or greater in the driver table, or less than 3 in the school bus table?

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


Question: What driver IDs are smaller than 1 in the driver table, or smaller 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 IDs of pets that are both owned by students other than student 1002 and are also cats weighing 9.3 pounds or more?

SELECT PetID FROM Has_Pet WHERE "StuID" <> 1002 INTERSECT SELECT PetID FROM Pets WHERE PetType = "cat" AND "weight" >= 9.3


Question: What are the Aircraft IDs that appear on both the list of aircraft with an ID of 2 or higher, and the list of airport aircraft, excluding those with an ID of 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 aircraft IDs from the aircraft table are 2 or less, but are not aircraft ID 3 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 = 3


Question: Show me the Final Table Made count, Earnings, Poker Player ID, People ID, Best Finish, and Money Rank for poker players who meet at least one of these conditions: Poker Player ID is 2 or less and Final Tables Made is 10 or more, Poker Player ID is not 1 and Final Tables Made is not 10, or People ID is 2 or more.

SELECT Final_Table_Made, Earnings, Poker_Player_ID, People_ID, Best_Finish, Money_Rank FROM poker_player WHERE "Poker_Player_ID" <= 2 AND "Final_Table_Made" >= 10.0 UNION ALL SELECT Final_Table_Made, Earnings, Poker_Player_ID, People_ID, Best_Finish, Money_Rank FROM poker_player WHERE "Poker_Player_ID" <> 1 AND "Final_Table_Made" != 10.0 OR "People_ID" >= 2


Question: What's the minimum city area for each store, considering only districts where either the city population isn't 530438, or the store ID is 1 or less, the city area isn't 22, and the district isn't 'Chiniot District'? Then, for these stores, only show those where either the store ID is greater than 1 and the city population is 134936, or the headquartered city isn't 'Khanewal City' and the district isn't 'Khanewal District'?

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


Question: What are the driver IDs that are not 5 from the drivers, and also those that are 7 or greater from the school buses?

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


Question: Which Aircraft IDs are in both the aircraft table, except for ID 5, and the airport_aircraft table, for IDs 3 and greater?

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: What driver IDs are either exactly 12, or 3 or greater in the school bus records?

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 less than 12 in the driver list, but not among those that are 7 or less in the school bus list?

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


Question: Could you provide the Driver IDs that are less than 4 from the driver table, or Driver ID 10 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 = 10


Question: What are the Branch IDs for branches not on Abbey Rise and not named Stanley, or with an ID greater than 5 and membership amount not equal to 56? Also, include Branch IDs from purchases made by members with ID at most 1, excluding branch ID '1', in years other than 2018, and for purchases up to 20.99 pounds.

SELECT Branch_ID FROM branch WHERE Address_road <> "Abbey Rise" AND Name != "Stanley" OR "Branch_ID" > 5 AND membership_amount <> "56" UNION ALL SELECT Branch_ID FROM purchase WHERE "Member_ID" <= 1 AND Branch_ID != "1" AND Year <> "2018" AND "Total_pounds" <= 20.99


Question: What are the smallest endowment IDs under two separate conditions: either the donor is not 'Monte Plata', or the amount is less than 8.43, or the endowment ID is not 9; and also when the donor is 'San José de Ocoa', the amount is greater than 9.73, the school ID is 3 or higher, and the endowment ID is 10 or higher?

SELECT MIN(endowment_id) FROM endowment WHERE donator_name <> "Monte Plata" OR "amount" < 8.43 OR "endowment_id" <> 9 UNION SELECT MIN(endowment_id) FROM endowment WHERE "endowment_id" >= 10 AND donator_name = "San José de Ocoa" AND "amount" > 9.73 AND "School_id" >= 3


Question: What driver IDs are either number 11 from the drivers list, or not number 4 from the school bus list?

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 driver IDs are 11 or greater in the driver table, or 10 or less in the school bus table?

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


Question: For each of two different sets of conditions, what is the budget and the count of departments that meet those conditions?

SELECT Budget_in_Billions, COUNT(Creation) FROM department WHERE "Ranking" >= 5 AND "Budget_in_Billions" <> 439.3 OR "Num_Employees" < 112557.0 AND Name != "Homeland Security" AND Creation = "1989" UNION ALL SELECT Budget_in_Billions, COUNT(Creation) FROM department WHERE "Ranking" != 4 OR Creation != "2002" AND "Num_Employees" > 10600.0 OR "Budget_in_Billions" < 62.8 AND Name != "Housing and Urban Development"


Question: Which driver IDs under 9 are drivers but not school bus drivers, disregarding school bus driver 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 aircraft IDs are greater than 3 in the aircraft table but not less than 5 in the airport_aircraft table?

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


Question: What is the average year for budgets with an investment percentage not equal to 122.5%, excluding the average year for budgets not in 2006 if they are the same?

SELECT AVG(Year) FROM budget WHERE Budget_invested_percent <> "122.5" EXCEPT SELECT AVG(Year) FROM budget WHERE "Year" != 2006


Question: Which driver IDs are 11 or less from the drivers, but are not also driver IDs of 4 or more in the school bus list?

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


Question: What shipping agent codes are there for documents that are not document ID 3, are shipped by 'UP', were not received on '1996-07-27 03:30:40', and are either not 'Hard Drive' type or not 'working', excluding any codes that are also from reference shipping agents that are not 'UP' and described as 'q'?

SELECT shipping_agent_code FROM Documents WHERE "document_id" != 3 AND shipping_agent_code = "UP" AND receipt_date <> "1996-07-27 03:30:40" AND document_type_code != "Hard Drive" OR document_status_code != "working" EXCEPT SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_code <> "UP" AND shipping_agent_description = "q"


Question: For student 1007, for each position, what are the total Club ID and the Club ID, for clubs that are not in 'HHH', or are 'Tennis Club' unless the position is 'Teaching Coordinator'?

SELECT SUM(T1.ClubID), T2.ClubID FROM Club as T1 JOIN Member_of_club as T2 ON T1.ClubID = T2.ClubID WHERE ClubLocation <> "HHH" OR ClubName = "Tennis Club" AND Position <> "Teaching Coordinator" GROUP BY Position HAVING StuID = 1007


Question: What are the common driver IDs for drivers with IDs under 11 and school bus drivers with IDs under 7?

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


Question: What driver IDs are in both the driver and school bus lists and are 7 or less?

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


Question: What are the Aircraft IDs that are not 3 in the aircraft table, or are 5 or less 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 <= 5


Question: What are the regions, and for each region, what is the highest Club ID, the number of club names, and the number of start years, but only for regions that meet at least one of these conditions: (1) Regions that include clubs that are either (started in 2001 or later and not named 'AIK'), or have ID 5, or are not from Korea, and also have exactly one start year or more than two club names. (2) Regions that include clubs that are not Club ID 2, and also have at least one club name?

SELECT Region, MAX(Club_ID), COUNT(Club_name), COUNT(Start_year) FROM club WHERE "Start_year" >= 2001 AND Club_name <> "AIK" OR "Club_ID" = 5 OR Region <> "Korea" GROUP BY Region HAVING COUNT(Start_year) = 1 OR COUNT(Club_name) > 2 UNION SELECT Region, MAX(Club_ID), COUNT(Club_name), COUNT(Start_year) FROM club WHERE "Club_ID" != 2 GROUP BY Region HAVING COUNT(Club_name) >= 1


Question: Is the average role code of employees the same as the average role code for roles with the code 'ED'?

SELECT AVG(role_code) FROM Employees WHERE employee_name != "Erling" AND role_code = "ED" OR "employee_id" != 1 OR other_details != "b" INTERSECT SELECT AVG(role_code) FROM Roles WHERE role_code = "ED"


Question: Which driver IDs are in the driver list, excluding driver ID 12, but not including any driver IDs less than 9 that are in the school bus list?

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


Question: Show me the driver IDs that are not 8 from the driver list, and also those driver IDs from the school bus list that are less than 4.

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: Which driver IDs from the driver table are 3 or less, excluding any driver IDs that are also driver ID 10 in the school_bus table?

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


Question: What driver IDs are greater than 2, except for driver ID 7 if it is also a school bus driver?

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 counts, average principal activities, group equity shareholdings, earliest names, latest incorporation locations, and earliest types of companies in two groups: first, those not from Hong Kong, not named 'Cathay Pacific Holidays', or not doing 'Cargo airline'; and second, those not ID 12, with less than 100% equity, or not 'Laundry' and not 'Joint Venture'?

SELECT COUNT(id), AVG(Principal_activities), Group_Equity_Shareholding, MIN(name), MAX(Incorporated_in), MIN(Type) FROM operate_company WHERE Incorporated_in != "Hong Kong" OR name != "Cathay Pacific Holidays" OR Principal_activities != "Cargo airline" UNION SELECT COUNT(id), AVG(Principal_activities), Group_Equity_Shareholding, MIN(name), MAX(Incorporated_in), MIN(Type) FROM operate_company WHERE "id" <> 12 OR "Group_Equity_Shareholding" < 100.0 OR Principal_activities != "Laundry" AND Type <> "Joint Venture"


Question: What Template Type Codes are both not 'PP' or not 'Paper' in template types, and also belong to templates effective until '2015-09-06 01:08:44' with either version not 4 and ID not 6, or having template details?

SELECT Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Code <> "PP" OR Template_Type_Description != "Paper" INTERSECT SELECT Template_Type_Code FROM Templates WHERE Date_Effective_To = "2015-09-06 01:08:44" AND "Version_Number" <> 4 AND "Template_ID" <> 6 OR Template_Details <> ""


Question: What are the total sum of disk areas, maximum disk loading, and average aircraft ID for Robinson R-22 aircraft that have a total disk area of 5,655 ft² (526 m²), are not heavy-lift helicopters, and do not have a max gross weight of 3,200 lb (1,451 kg), excluding those that also are not CH-47D Chinook, are not light utility helicopters, and do not have a max disk loading of 3.7 lb/ft² (18 kg/m²) or a max gross weight of 1,370 lb (635 kg)?

SELECT SUM(Total_disk_area), Max_disk_Loading, AVG(Aircraft_ID) FROM aircraft WHERE Total_disk_area = "5,655 ft² (526 m²)" AND Max_Gross_Weight != "3,200 lb (1,451 kg)" AND Description <> "Heavy-lift helicopter" AND Aircraft = "Robinson R-22" EXCEPT SELECT SUM(Total_disk_area), Max_disk_Loading, AVG(Aircraft_ID) FROM aircraft WHERE Aircraft <> "CH-47D Chinook" AND Description <> "Light utility helicopter" AND Max_disk_Loading <> "3.7 lb/ft² (18 kg/m²)" AND Max_Gross_Weight <> "1,370 lb (635 kg)"


Question: Which driver IDs greater than 4 are in both the driver and school bus lists?

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 maximum first name, birth date, and last name of customers who are not customer ID 7, or became customers on 2016-04-08 00:28:15, or are 'Bad Customers', or have email 'afranecki@example.com', or whose last name is not 'Spinka', or have cell phone '1-387-258-1016x96963' and a first name other than 'Genevieve', excluding those who are also staff members that either don't have 'Amara' as a middle name or are nicknamed 'thompson.constantin'?

SELECT MAX(first_name), date_of_birth, last_name FROM Customers WHERE "customer_id" <> 7 OR date_became_customer = "2016-04-08 00:28:15" OR customer_status_code = "Bad Customer" OR email_address = "afranecki@example.com" OR last_name <> "Spinka" OR cell_mobile_phone_number = "1-387-258-1016x96963" AND first_name != "Genevieve" EXCEPT SELECT MAX(first_name), date_of_birth, last_name FROM Staff WHERE middle_name != "Amara" OR nickname = "thompson.constantin"


Question: Which employee IDs are common to employees who have records in the circulation history for documents with IDs less than 10 and copy numbers not equal to 5, and employees who are either not named Erling, or have an ID of 5, or have other details that are not 'f'?

SELECT employee_id FROM Circulation_History WHERE "document_id" < 10 AND "copy_number" != 5 INTERSECT SELECT employee_id FROM Employees WHERE employee_name != "Erling" OR "employee_id" = 5 OR other_details != "f"


Question: Which Aircraft IDs are greater than 3 in the aircraft table, or are exactly 3 in the airport_aircraft table?

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


Question: What driver IDs are 3 or greater in the driver table, but not also 4 or greater in the school bus table?

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


Question: What are the number of beds, bed type count, room ID, and base price for rooms that are either not for couples, or priced under $175, or are 2-bed double rooms with non-rustic decor, and also for rooms that are king bed type, have more than 2 beds, and are not for 4 people?

SELECT beds, COUNT(bedType), RoomId, basePrice FROM Rooms WHERE "maxOccupancy" <> 2 OR "basePrice" < 175 OR "beds" = 2 AND decor != "rustic" AND bedType = "Double" UNION ALL SELECT beds, COUNT(bedType), RoomId, basePrice FROM Rooms WHERE "beds" > 2 AND bedType = "King" AND "maxOccupancy" != 4


Question: What are the Driver IDs that are less than or equal to 1 from the driver table or greater than or equal to 10 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 >= 10


Question: What driver IDs are drivers, excluding ID 8, but are not school bus drivers with IDs 4 or greater?

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 driver IDs, other than 5, are in the driver table but not in the school bus table for IDs 10 or greater?

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


Question: What is the total age, number of first names, last names, majors, and sum of sex for students who are not named George, have an advisor value less than 5718, are 22 years old, are not 17 years old, or are male and not from city PIT?

SUM(Age) COUNT(Fname) LName Major SUM(Sex)

SELECT SUM(Age), COUNT(Fname), LName, Major, SUM(Sex) FROM Student WHERE Fname <> "George" OR "Advisor" < 5718 OR "Age" = 22 UNION SELECT SUM(Age), COUNT(Fname), LName, Major, SUM(Sex) FROM Student WHERE "Age" != 17 OR Sex = "M" AND city_code != "PIT"


Question: What Driver IDs are both not equal to 9 and also less than or equal to 7?

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 other details and document IDs for documents that are not document 3540024 or have 'None' as other details, except if they are also found in paragraphs that are not 'None' in other details, or have a paragraph ID greater than 9946, or have paragraph text other than 'Micronesia'?

SELECT Other_Details, Document_ID FROM Documents WHERE "Document_ID" != 3540024 OR Other_Details = "None" EXCEPT SELECT Other_Details, Document_ID FROM Paragraphs WHERE Other_Details != "None" OR "Paragraph_ID" > 9946 OR Paragraph_Text != "Micronesia"


Question: What driver IDs are present in both the driver list (excluding driver 12) and the school bus driver list (for IDs 9 or greater)?

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


Question: What driver IDs are both drivers with IDs greater than 4 and school bus drivers with ID 10?

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


Question: What Aircraft IDs are 3 or greater in the aircraft table, excluding those that are less than 1 in the airport_aircraft table?

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


Question: Which driver IDs that are less than 3 are drivers, but are not school bus drivers with IDs up to 7?

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


Question: What driver IDs are in both the driver and school bus lists and are 4 or less?

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


Question: What are the driver IDs that are greater than 10, excluding any driver IDs greater than or equal to 7 that are also used for school buses?

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


Question: What are the Driver IDs that are less than 6 from the driver list, and also those that are not 7 from the school bus list?

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


Question: What are the Driver IDs that are not 3 from the driver table, or are 9 or greater from the school_bus table?

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


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

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


Question: Which aircraft IDs are 5 or greater in the aircraft table, but are not aircraft ID 3 in the airport_aircraft table?

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


Question: What Aircraft IDs are common to both the aircraft and airport_aircraft tables, excluding ID 5 from the aircraft table and only considering IDs greater than 1 from the airport_aircraft table?

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


Question: What driver IDs are both on the list of drivers, excluding driver 12, and on the list of school bus drivers with ID 9 or higher?

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


Question: What is an aircraft ID that is in both the aircraft and airport aircraft lists, and what is the smallest aircraft ID in the airport aircraft list for aircraft also in the aircraft list?

SELECT T1.Aircraft_ID, MIN(T2.Aircraft_ID) FROM aircraft as T1 JOIN airport_aircraft as T2 ON T1.Aircraft_ID = T2.Aircraft_ID


Question: What are the item IDs for items named 'avocado', and also item IDs that are 3 in the reviews?

SELECT i_id FROM item WHERE title = "avocado" UNION ALL SELECT i_id FROM review WHERE "i_id" = 3


Question: What are the driver IDs that are 5 or less in the driver list, but not among the driver IDs that are 4 or less in the school bus list?

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


Question: Which driver IDs are in the driver list, except for driver ID 10, and are not also in the school bus list for IDs 7 or greater?

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


Question: What are the driver IDs that are 3 or greater from the driver list, or 10 or greater from the school bus list?

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


Question: Which Driver IDs are greater than 6 for drivers, or not 7 for school buses?

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


Question: What is the average creation time, the minimum vote ID, the minimum state, and the phone number for votes that meet either of these conditions: either the contestant number is not 5, or the vote ID is 5 or less and the phone number is not 5112677315 and the creation time is not "2018-03-09 19:03:40", or the state is not NY; or the contestant number is less than 5, or the phone number is 5112677315 or less, or the creation time is "2018-03-09 19:03:39" and the vote ID is 2, or the state is NJ?

SELECT AVG(created), MIN(vote_id), MIN(state), phone_number FROM VOTES WHERE "contestant_number" <> 5 OR "vote_id" <= 5 AND "phone_number" != 5112677315 AND created != "2018-03-09 19:03:40" OR state != "NY" UNION ALL SELECT AVG(created), MIN(vote_id), MIN(state), phone_number FROM VOTES WHERE "contestant_number" < 5 OR "phone_number" <= 5112677315 OR created = "2018-03-09 19:03:39" AND "vote_id" = 2 OR state = "NJ "


Question: What Driver IDs are 11 or less from the driver list, or are exactly 10 from the school bus list?

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


Question: Which driver IDs are greater than 11 and listed as drivers, but are not listed as school bus drivers with IDs of 10 or greater?

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


Question: What aircraft IDs from the aircraft table, other than 4, are not also ID 1 in the airport aircraft table?

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


Question: What are the school IDs of schools not in Walkerton, except for those with budget records from 1999 or earlier, or 146.9% invested, or invested less than 8335 and budgeted over 6803?

SELECT School_id FROM School WHERE Location != "Walkerton" EXCEPT SELECT School_id FROM budget WHERE "Year" <= 1999 OR Budget_invested_percent = "146.9" OR "Invested" < 8335 AND "Budgeted" > 6803


Question: Which driver IDs are both not equal to 5 and listed as a driver, and also at least 9 and listed as a school bus driver?

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


Question: Which driver IDs are greater than 2 from the driver list, or not equal to 3 from the school bus list?

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


Question: Give me driver ID 11 if it is a driver but not in the school bus records.

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 less than 3 in the driver table or greater than 3 in the school bus table?

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


Question: Which driver IDs are 6 or higher in the driver table, but not among the driver IDs less than 4 in the school bus table?

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


Question: What driver IDs, other than 8 and 4, are in the driver table?

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


Question: What are the Aircraft IDs that are less than 4 in the aircraft records or not equal to 2 in the airport aircraft records?

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


Question: Which driver IDs are drivers with IDs greater than 7, but are not school bus drivers with IDs of 7 or more?

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


Question: What are the Driver IDs that are 8 or less from the drivers, or not equal to 3 from the school buses?

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


Question: Which driver IDs are less than 8 from the driver table, and also driver ID 9 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 = 9


Question: What aircraft IDs are number 1 in the aircraft records or less than 3 in the airport aircraft records?

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


Question: What driver IDs are both less than or equal to 8 and not equal to 9, considering drivers and school bus drivers?

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


Question: What are the distances and employee IDs for aircraft certificates, grouped by employee ID, but only for groups that include employee ID 356187925, or have an aircraft that is not a Boeing 757-300 and has a distance other than 3383?

SELECT T1.distance, T2.eid FROM aircraft as T1 JOIN certificate as T2 ON T1.aid == T2.aid GROUP BY eid HAVING name <> "Boeing 757-300" AND distance <> 3383 OR eid = 356187925


Question: What are the different types of stores that are either not ranked 3, or are named 'Neguac', or have a number of product categories other than 793, or have an area size other than 21.73 and a ranking other than 3, or have a store ID greater than 4?

SELECT Type FROM store WHERE "Number_of_product_category" <> 793.0 OR Store_Name = "Neguac" OR "Area_size" <> 21.73 AND "Ranking" <> 3 OR "Store_ID" > 4 UNION SELECT Type FROM store WHERE "Ranking" <> 3


Question: What are the driver IDs that are less than 8, but not among the school bus driver IDs that are greater than 7?

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 Driver IDs that are greater than 2 or not equal to 10?

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


Question: Can you give me a list of Template IDs from the Documents table where the Document Name is not "About Korea", or the Other Details are not "None", or the Document Description is "w", combined with a list of Template IDs from the Templates table where the Date Effective To is not "2001-04-18 09:29:52", the Template Type Code is "PPT", and the Template ID is greater than or equal to 11?

SELECT Template_ID FROM Documents WHERE Document_Name != "About Korea" OR Other_Details <> "None" OR Document_Description = "w" UNION SELECT Template_ID FROM Templates WHERE Date_Effective_To != "2001-04-18 09:29:52" AND Template_Type_Code = "PPT" AND "Template_ID" >= 11


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

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


Question: What aircraft IDs, excluding aircraft ID 5, are also aircraft IDs excluding aircraft ID 2, that are found in the airport aircraft table?

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: Can you list all department IDs from the management table where the head ID is greater than 10, and also list all department IDs from the management table where the head ID is greater than 3, including any duplicates?

SELECT department_ID FROM management WHERE "head_ID" > 10 UNION ALL SELECT department_ID FROM management WHERE "head_ID" > 3


Question: Can you give me a list of aircraft IDs, excluding aircraft ID 4, and combine it with a list of aircraft IDs from the airport aircraft table, excluding aircraft ID 1?

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

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


Question: Can you give me a list of driver IDs that are less than 7 from the driver table, combined with a list of driver IDs that are 3 or greater from the school bus table, making sure to remove any duplicates?

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


Question: Can you give me a list of all the driver IDs, excluding driver ID 9, from both the driver and school bus records?

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


Question: Can you give me a list of all item titles, including those that aren't shampoo and those with an i_id less than 5?

SELECT title FROM item WHERE title <> "shampoo" UNION ALL SELECT title FROM item WHERE "i_id" < 5


Question: Which driver IDs appear in the driver list, excluding driver ID 6, and also appear in the school bus list, excluding driver ID 3?

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


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

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 is the smallest document ID from the Circulation History where the copy number is 10, the document ID is less than or equal to 2, and the employee ID is 2, excluding the smallest document ID from the Documents table where the receipt number is not 189, and either the other details are not "u" or the receipt date is "1996-07-27 03:30:40" and the shipping agent code is not "FE"?

SELECT MIN(document_id) FROM Circulation_History WHERE "copy_number" = 10 AND "document_id" <= 2 AND "employee_id" = 2 EXCEPT SELECT MIN(document_id) FROM Documents WHERE receipt_number <> "189" AND other_details != "u" OR receipt_date = "1996-07-27 03:30:40" AND shipping_agent_code <> "FE"


Question: Could you list the District IDs from the district table where the District ID is less than or equal to 13, or the City Population is less than or equal to 365198, or where the District Name is not "Dera Ghazi Khan District" but the Headquartered City is "Bahawalpur City" and the City Area is not 15, combined with the District IDs from the store_district table where the Store ID is not 1 or the District ID is greater than or equal to 4?

SELECT District_ID FROM district WHERE "District_ID" <= 13 OR "City_Population" <= 365198.0 OR District_name != "Dera Ghazi Khan District" AND Headquartered_City = "Bahawalpur City" AND "City_Area" != 15.0 UNION SELECT District_ID FROM store_district WHERE "Store_ID" != 1 OR "District_ID" >= 4


Question: Can you give me a list of driver IDs, removing driver ID 10 from the driver list and driver ID 7 from the school bus list, showing each driver ID only once?

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


Question: Can you list all driver IDs from the driver table that are 10 or greater, and combine that with a list of all driver IDs from the school_bus table that are less than 9?

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: Can you give me a list of driver IDs from the driver table that are less than or equal to 5, combined with a list of driver IDs from the school_bus table that are not equal to 9?

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


Question: Which aircraft IDs, excluding ID 2, are 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 <> 2


Question: Can you list the driver IDs from the driver table that are less than or equal to 5, and combine that with a list of driver IDs from the school_bus table that are greater than 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: Could you list the draft number, draft details, and document ID from the document drafts table, including entries where the draft number isn't zero, the draft details aren't "w", and the document ID is greater than 4, as well as entries where the draft number is less than 1, or the document ID is less than or equal to 13 and the draft details aren't "k"?

SELECT draft_number, draft_details, document_id FROM Document_Drafts WHERE "draft_number" <> 0 AND draft_details <> "w" AND "document_id" > 4 UNION ALL SELECT draft_number, draft_details, document_id FROM Document_Drafts WHERE "draft_number" < 1 OR "document_id" <= 13 AND draft_details <> "k"


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

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


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

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


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

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


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

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


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

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


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

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


Question: Can you list the mailing date, document ID, and mailed-to address ID for all documents mailed, including those with a non-zero mailed-to address ID, and also specifically those with document ID 4 and mailed-to address ID 8?

SELECT mailing_date, document_id, mailed_to_address_id FROM Documents_Mailed WHERE "mailed_to_address_id" <> 0 UNION ALL SELECT mailing_date, document_id, mailed_to_address_id FROM Documents_Mailed WHERE "document_id" = 4 AND "mailed_to_address_id" = 8


Question: Can you list the rank and coach ID for all coaches who are not female and are not rank 4, or who have a club ID greater than 1, combined with the rank and coach ID for coaches who are rank 2, have a coach ID of 5 or greater, have a club ID of 1 or less, or whose name is not Joe Fabbri and are not male?

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


Question: Can you list all document status descriptions, including those with the code "done", but excluding "mailed late"?

SELECT document_status_description FROM Ref_Document_Status WHERE document_status_description != "mailed late" UNION SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "done"


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

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


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

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


Question: Can you give me a list of Model IDs, including those where the Maker is 16 or higher, and also those where the Maker is not 6 or the Model is not a Cadillac?

SELECT ModelId FROM model_list WHERE "Maker" >= 16 UNION SELECT ModelId FROM model_list WHERE "Maker" != 6 OR Model <> "cadillac"


Question: Can you give me a list of school IDs, including those from schools that are either not Occidental College and are located in Jakarta, Indonesia, or are public schools, or serve junior and senior year students, combined with school IDs from the school bus table where either the School_ID is not 7 or the Driver_ID is less than 7?

SELECT School_ID FROM school WHERE School != "Occidental College" AND Location = "Jakarta, Indonesia" OR Type = "Public" OR Grade = "Junior–Senior year" UNION SELECT School_ID FROM school_bus WHERE "School_ID" <> 7 OR "Driver_ID" < 7


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

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


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

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


Question: Can you give me a list of vehicle IDs, combining those from lessons where the staff ID is greater than 4, or the customer ID is less than or equal to 13 and the lesson isn't cancelled, or the lesson time is 2, or the vehicle ID is greater than 3, or the price is exactly 492, or the lesson ID isn't 2, with those from vehicles where the vehicle ID isn't 3 and the vehicle details aren't "Car"?

SELECT vehicle_id FROM Lessons WHERE "staff_id" > 4 OR "customer_id" <= 13 AND lesson_status_code <> "Cancelled" OR lesson_time = "2" OR "vehicle_id" > 3 OR "price" = 492.0 OR "lesson_id" != 2 UNION ALL SELECT vehicle_id FROM Vehicles WHERE "vehicle_id" <> 3 AND vehicle_details <> "Car"


Question: Can you give me the average student ID and age, along with the first name, minimum advisor and city code, and maximum last name, grouped by sex, for students where either the advisor is less than 1121, the age is 20, the sex is not male, and the city code is not PIT, or the first name is not Paul and the student ID is 1003, but excluding those students where the age is 20 or greater, the sex is female, the major is 600, or the last name is Adams?

Sex AVG(StuID) AVG(Age) Fname MIN(Advisor) MIN(city_code) MAX(LName)

SELECT Sex, AVG(StuID), AVG(Age), Fname, MIN(Advisor), MIN(city_code), MAX(LName) FROM Student WHERE "Advisor" < 1121 AND "Age" = 20 AND Sex <> "M" AND city_code <> "PIT" OR Fname != "Paul" AND "StuID" = 1003 EXCEPT SELECT Sex, AVG(StuID), AVG(Age), Fname, MIN(Advisor), MIN(city_code), MAX(LName) FROM Student WHERE "Age" >= 20 AND Sex = "F" OR "Major" = 600 OR LName = "Adams"


Question: Which aircraft IDs are both less than or equal to 3 and present in the airport aircraft list where the aircraft ID is exactly 3?

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


Question: Can you give me a list of driver IDs that are either exactly 12 from the driver table, or greater than 7 from the school bus table?

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


Question: Can you list all the aircraft IDs, excluding aircraft ID 3, from both the aircraft and airport_aircraft lists?

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


Question: Can you give me a list of driver IDs, including those from the driver table where the ID is greater than 2, and those from the school bus table where the ID is less than or equal to 4?

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


Question: Can you give me a list of driver IDs that are greater than 7, excluding any driver IDs that also appear in the school bus table, unless that driver ID is 10?

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


Question: Can you list the draft numbers and document IDs for all documents with an ID less than 13, along with the draft numbers and document IDs for all draft copies that have a draft number of 8 but a copy number that isn't 15?

SELECT draft_number, document_id FROM Document_Drafts WHERE "document_id" < 13 UNION SELECT draft_number, document_id FROM Draft_Copies WHERE "draft_number" = 8 AND "copy_number" <> 15


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

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


Question: Which aircraft IDs, excluding aircraft ID 4, are also aircraft IDs that are greater than or equal to 5 in the airport aircraft list?

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


Question: Can you list the aircraft IDs, first from the aircraft table excluding aircraft ID 2, and then from the airport_aircraft table including only aircraft IDs that are 2 or greater?

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


Question: Can you give me a list of feature IDs from the Other_Available_Features table, excluding feature ID 2, where the feature type is "Amenity" and the feature description isn't "Burglar Alarm", or the feature name is "Pool", combined with a list of feature IDs from the Other_Property_Features table, excluding feature ID 3 or property ID 6?

SELECT feature_id FROM Other_Available_Features WHERE "feature_id" <> 2 AND feature_type_code = "Amenity" AND feature_description <> "Burglar Alarm" OR feature_name = "Pool" UNION SELECT feature_id FROM Other_Property_Features WHERE "feature_id" <> 3 OR "property_id" <> 6


Question: Can you give me the IDs of people who are not named Yevgeni Sivozhelez, or who are Russian born on July 14, 1983, or are at least 207 cm tall, excluding those poker players with an ID other than 4?

SELECT People_ID FROM people WHERE Name <> "Yevgeni Sivozhelez" OR "People_ID" <> 1 AND Nationality = "Russia" AND Birth_Date = "July 14, 1983" OR "Height" >= 207.0 EXCEPT SELECT People_ID FROM poker_player WHERE "Poker_Player_ID" != 4


Question: Which driver IDs, that are 6 or greater, are not also driver IDs in the school bus table, excluding driver ID 10 from that 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: Can you give me a list of driver IDs, including those from the driver table where the ID is 7 or higher, and those from the school bus table where the ID is not 4?

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


Question: Can you give me a list of driver IDs, including those from the driver table that are not 6, and those from the school bus table that are exactly 10?

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


Question: Can you give me a list of driver IDs that are not 11 from the driver table, but are also less than 10 from the school bus table?

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


Question: Can you give me a list of driver IDs, including those from the driver table excluding driver ID 6, and those from the school_bus table with driver IDs of 7 or higher?

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


Question: Can you give me a list of employee names from the employee table where the name is Lee Mears, or the age is less than or equal to 29 and the employee ID is not 6, or the city is Bristol, combined with a list of shop names from the shop table where the shop ID is greater than or equal to 5 and the manager's name is not Job Dragtsma, or the name is FC Lahti, or the number of products is less than 5000, or the district is not Arto Tolsa Areena and the location is not Kuopio?

SELECT Name FROM employee WHERE Name = "Lee Mears" OR "Age" <= 29 AND "Employee_ID" <> 6 OR City = "Bristol" UNION SELECT Name FROM shop WHERE "Shop_ID" >= 5 AND Manager_name <> "Job Dragtsma" OR Name = "FC Lahti" OR "Number_products" < 5000 OR District != "Arto Tolsa Areena" AND Location <> "Kuopio"


Question: What is the highest feature type code from the available features, excluding "BurglarAlarm" feature names and only considering feature IDs of 3 or greater, also excluding "Security" feature type codes, except for the highest feature type code from the feature types reference table, excluding "Amenity, eg Pool." feature type names?

SELECT MAX(feature_type_code) FROM Other_Available_Features WHERE feature_name != "BurglarAlarm" AND "feature_id" >= 3 AND feature_type_code != "Security" EXCEPT SELECT MAX(feature_type_code) FROM Ref_Feature_Types WHERE feature_type_name <> "Amenity, eg Pool."


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

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


Question: Can you give me the total club ID and average coach name, broken down by gender, for coaches where the club ID is 1 or greater, combined with the same information for coaches where their rank is greater than 1, their coach ID is not 2, or their gender is not male and their club ID is 1 or greater?

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


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

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


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

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


Question: Can you list the document type descriptions for both "Paper" and "Hard Drive"?

SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper" UNION ALL SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Hard Drive"


Question: Which aircraft IDs are both less than 5 (when considering all aircraft) and equal to 2 (when considering aircraft at airports)?

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: Can you give me a list of member IDs for people from LaGrange, Georgia, along with member IDs from the membership register for any year other than 2016?

SELECT Member_ID FROM member WHERE Hometown = "LaGrange, Georgia" UNION ALL SELECT Member_ID FROM membership_register_branch WHERE Register_Year != "2016"


Question: Can you list all the aircraft IDs, first from the aircraft table where the ID is not 1, and then from the airport_aircraft table where the ID is 3 or greater?

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


Question: Could you list the draft numbers from the circulation history where the copy number is not 10, and also include draft number 8 from the document drafts if its document ID is less than 12?

SELECT draft_number FROM Circulation_History WHERE "copy_number" != 10 UNION SELECT draft_number FROM Document_Drafts WHERE "draft_number" = 8 AND "document_id" < 12


Question: Which driver IDs are not equal to 2 and are also less than or equal to 3?

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


Question: Can you list the aircraft IDs that are both less than or equal to 5 in the aircraft table and greater than 2 in the airport_aircraft table?

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: Can you list all the driver IDs from the driver table that are less than or equal to 4, and combine that with a list of all driver IDs from the school_bus table that are not equal to 4?

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


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

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

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


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

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 appear in both the driver list where the ID is 7 and the school bus list where the ID is 9 or less?

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


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

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: Which driver IDs are greater than 3 and also less than or equal to 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: How many members are there, what's the average city value, how many names are there, and what are the branch IDs for branches on Abbey Rise, combined with the same information for branches that weren't opened in 2009 and don't have a membership amount of 112?

SELECT COUNT(membership_amount), AVG(City), COUNT(Name), Branch_ID FROM branch WHERE Address_road = "Abbey Rise" UNION ALL SELECT COUNT(membership_amount), AVG(City), COUNT(Name), Branch_ID FROM branch WHERE Open_year != "2009" AND membership_amount <> "112"


Question: What is the sum of Branch IDs from the branch table where the address is Glebe Street, the Branch ID is less than 4, and the city is not London, or the membership amount is not 1418, excluding the sum of Branch IDs from the purchase table where the total pounds is greater than or equal to 988.09 or the Branch ID is not 2?

SELECT SUM(Branch_ID) FROM branch WHERE Address_road = "Glebe Street" AND "Branch_ID" < 4 AND City != "London" OR membership_amount <> "1418" EXCEPT SELECT SUM(Branch_ID) FROM purchase WHERE "Total_pounds" >= 988.09 OR Branch_ID != "2"


Question: Can you give me a list of aircraft IDs that appear in the aircraft table, excluding aircraft ID 3, but then remove any aircraft IDs from that list that also appear in the airport_aircraft table with an ID of 5 or greater?

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


Question: Can you give me a list of driver IDs that are not equal to 1 from the driver table, but only include those driver IDs that are also less than 9 from the school_bus table?

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


Question: What are the average item IDs and corresponding ranks for items and reviews, considering only the data where the user ID is greater than 2, the rank is less than 3, the assistant ID is greater than 1, the title is "comb", or the rating is less than or equal to 6?

SELECT AVG(T1.i_id), T2.rank FROM item as T1 JOIN review as T2 ON T1.i_id = T2.i_id WHERE "u_id" > 2 OR "rank" < 3 OR "a_id" > 1 OR title = "comb" OR "rating" <= 6


Question: Can you give me a list of driver IDs, where each ID is 12 or greater, but excluding any driver ID that appears in the school bus list, unless that ID is 3?

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


Question: Can you give me a list of aircraft IDs that are less than 2, but also not equal to 5 when looking at airport aircraft?

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: Can you list the aircraft IDs that are equal to 4 from the aircraft table, and also list the aircraft IDs that are less than or equal to 5 from the airport_aircraft table, combining both lists into one?

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


Question: Can you give me a list of aircraft IDs that are less than 5, excluding any aircraft IDs greater than 3 that are also found in the airport aircraft list?

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


Question: Can you give me a list of store IDs that sell products other than product 6, combined with a list of store IDs that sell products other than product 1?

SELECT Store_ID FROM store_product WHERE "Product_ID" != 6 UNION SELECT Store_ID FROM store_product WHERE "Product_ID" <> 1


Question: Can you list the Aircraft IDs that are less than 4, first from the aircraft table, and then from the airport_aircraft table, removing any duplicates?

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


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

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


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

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


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