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

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


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

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


Question: What aircraft IDs, other than 1, are in the aircraft table but not in the airport_aircraft table, ignoring aircraft ID 5 in the airport_aircraft table?

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


Question: Could you list driver ID 7 from the driver records and also all driver IDs up to 9 from 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: For each year and party, what are the minimum Attorney General and total Lieutenant Governor when either the US Senator is not Charles Schumer or the Comptroller is not Carl McCall, or when the Comptroller is not Alan Hevesi, or if the Governor is not Peter Vallone for the 'Working Families' party with Party ID up to 7, or if the Lieutenant Governor is not Jonathan Reiter?

SELECT Year, Party, MIN(Attorney_General), SUM(Lieutenant_Governor) FROM party WHERE US_Senate <> "Charles Schumer" OR Comptroller != "Carl McCall" UNION SELECT Year, Party, MIN(Attorney_General), SUM(Lieutenant_Governor) FROM party WHERE Comptroller <> "Alan Hevesi" OR Governor != "Peter Vallone" AND Party = "Working Families" AND "Party_ID" <= 7 OR Lieutenant_Governor != "Jonathan Reiter"


Question: What driver IDs are 6 or greater in the driver table, but not driver ID 10 from the school bus table?

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


Question: What are the Driver IDs, including all IDs except 5 from the driver list, and also ID 7 from the school bus list?

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


Question: What are the driver IDs that are less than 8 in the driver list, or less than or equal to 10 in the school bus list?

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 allergy types and allergies are there for soy (except animal allergies), shellfish, or any allergy type that isn't environmental?

SELECT AllergyType, Allergy FROM Allergy_Type WHERE AllergyType != "animal" AND Allergy = "Soy" UNION SELECT AllergyType, Allergy FROM Allergy_Type WHERE Allergy = "Shellfish" OR AllergyType != "environmental"


Question: What Aircraft IDs are both less than 4 in the aircraft table and also equal to 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 born states, head IDs, and minimum names for heads who are older than 52, as well as for heads with a head ID less than 3 and not from Alabama?

SELECT born_state, head_ID, MIN(name) FROM head WHERE "age" > 52.0 UNION ALL SELECT born_state, head_ID, MIN(name) FROM head WHERE "head_ID" < 3 AND born_state != "Alabama"


Question: Can you list all store IDs that are either greater than 4 or are in a district other than 15?

SELECT Store_ID FROM store_district WHERE "Store_ID" > 4 UNION ALL SELECT Store_ID FROM store_district WHERE "District_ID" != 15


Question: Which driver IDs are drivers (excluding ID 3) but are not also school bus drivers with an ID of 9 or less?

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


Question: What are the average purchase year, minimum total pounds, and member IDs for purchases that are either not from branch 5, or from members other than 2 and not in 2018, or from 2018, or not from branch 6?

SELECT AVG(Year), MIN(Total_pounds), Member_ID FROM purchase WHERE Branch_ID <> "5" OR "Member_ID" <> 2 AND Year != "2018" UNION SELECT AVG(Year), MIN(Total_pounds), Member_ID FROM purchase WHERE Year = "2018" OR Branch_ID != "6"


Question: What driver IDs are both greater than 6 and not equal to 10, and are listed in both the driver and school bus tables?

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


Question: What Aircraft IDs are listed in both the aircraft and airport aircraft tables, except for ID 4 in the aircraft table and ID 5 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 <> 5


Question: Which driver IDs, less than 6, are drivers but not school bus drivers?

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 driver ID is on the driver list, but not driver 3, and is also driver 4 on the school bus list?

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


Question: Which driver IDs, other than 12, are drivers but are not school bus drivers with IDs greater than 7?

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: What are the driver IDs that are both not equal to 5 in the driver list and greater than or equal to 9 in the school bus list?

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: Is driver ID 4 also listed as a school bus driver with an ID of 7 or less?

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


Question: What is employee number 3's lowest role code, and also, what is the role code 'PT'?

SELECT MIN(role_code) FROM Employees WHERE "employee_id" = 3 UNION ALL SELECT MIN(role_code) FROM Roles WHERE role_code = "PT"


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


Question: What driver IDs are 10 or less from the driver list, or not 3 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: Which driver IDs are greater than 7, but not driver ID 3 from the school bus records?

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 driver IDs are greater than 8 but are not also school bus driver IDs (considering only school bus driver IDs of 3 or more)?

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


Question: Which driver IDs, other than 9, are drivers but not school bus drivers with ID 7?

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


Question: Which drivers, other than driver ID 10, are not also school bus drivers, excluding school bus driver ID 3?

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


Question: What are the unique Aircraft IDs that are either ID 4 from the aircraft table, or less than or equal to 5 from the airport aircraft table?

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


Question: Which aircraft IDs are present in both the aircraft table (excluding ID 3) and the airport_aircraft table (only including IDs greater than 1)?

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


Question: What driver IDs are greater than 6, and also driver ID 7 if they are school bus drivers?

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 both greater than 2 and less than 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 driver ID is 6, excluding any school bus driver IDs greater than 10?

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


Question: Can you tell me, for each city population, the count of districts that meet any of the following conditions: population is less than 113524, or district ID is not 8 and area is 25 or more, or district name is not 'Hafizabad District', or headquartered city is 'Gujranwala City' and district name is not 'Hafizabad District', or area is 22?

SELECT City_Population, COUNT(City_Area) FROM district WHERE "City_Population" < 113524.0 OR "District_ID" <> 8 AND "City_Area" >= 25.0 OR District_name != "Hafizabad District" UNION ALL SELECT City_Population, COUNT(City_Area) FROM district WHERE Headquartered_City = "Gujranwala City" AND District_name != "Hafizabad District" OR "City_Area" = 22.0


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

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


Question: What is the highest rank in match results that meet certain performance criteria, unless that rank is also the highest rank among players who meet different criteria?

SELECT MAX(Rank) FROM match_result WHERE "Points" != 66 AND "Rank" <= 4 OR "Small_Silver" < 9 OR "Club_ID" != 5 AND "Gold" >= 5 AND "Big_Silver" <= 9 EXCEPT SELECT MAX(Rank) FROM player WHERE "Votes" = 9506 OR "Player_ID" < 1 AND Rank <> "1st" AND Occupation <> "Student"


Question: Which driver IDs are both greater than 8 and also appear in the school bus records with an ID of 7 or greater?

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


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

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


Question: What are the aircraft IDs that are both in the aircraft list with IDs of 2 or higher, and in the airport aircraft list with ID 3?

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


Question: What driver IDs are on both the list of drivers, excluding driver 12, and the list of school bus drivers, considering only those with IDs greater than 4?

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 driver IDs are both 10 or less and not 3, and are listed as both a driver and a school bus driver?

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


Question: What driver IDs are in the driver list, except for ID 7, and are not among the school bus driver IDs that are less than 3?

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


Question: What driver IDs are 1 or less and are drivers, but are not school bus drivers with IDs 10 or less?

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


Question: Which aircraft IDs, other than 4, are in the aircraft list but not in the airport aircraft list, excluding ID 5 from that list?

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


Question: Which continents and their IDs are both not ID 3 and also either ID 4 or greater, or are Europe?

SELECT Continent, ContId FROM continents WHERE "ContId" != 3 INTERSECT SELECT Continent, ContId FROM continents WHERE "ContId" >= 4 OR Continent = "europe"


Question: Which driver IDs, greater than 7, are recorded in both the driver and school bus tables?

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


Question: What driver IDs are listed as both a driver, excluding driver 9, and a school bus driver, excluding driver 4?

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


Question: What driver IDs are greater than 9 in the driver table, and which driver IDs are less than 9 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 < 9


Question: What Driver IDs are in both the driver list (and are 4 or greater) and the school bus list (but not 3)?

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


Question: What driver IDs are greater than 10 in the driver table but are not also greater than 7 in the school bus table?

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


Question: Is aircraft ID 3 in the aircraft table but not also 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 != 3


Question: What Aircraft IDs are both not equal to 1 in the aircraft table and equal to 2 in the airport_aircraft table?

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


Question: What driver IDs are in both the driver and school bus lists and are between 4 and 8?

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


Question: What aircraft IDs are in the aircraft table, excluding ID 3, or in the airport aircraft table, excluding ID 2?

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


Question: What Aircraft IDs are both less than 4 and greater than 2, considering the aircraft and airport aircraft information?

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 driver IDs are both 9 or less and also not equal to 4, considering drivers and school bus drivers?

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


Question: Which driver IDs are drivers, excluding driver ID 3, but are not school bus driver 4?

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


Question: What are the Aircraft IDs that are less than or equal to 1 from the aircraft table, or not equal to 5 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 != 5


Question: If the number of employees who in evaluations have a bonus of 2900 or more and employee ID '2', or were awarded in a year other than 2018, is different from the number of employees in hiring who started in a year other than 2011, what is the first number? Otherwise, what is zero?

SELECT COUNT(Employee_ID) FROM evaluation WHERE "Bonus" >= 2900.0 AND Employee_ID = "2" OR Year_awarded != "2018" EXCEPT SELECT COUNT(Employee_ID) FROM hiring WHERE Start_from != "2011"


Question: What is the Aircraft ID that is number 3 and is listed in both the aircraft and airport aircraft tables?

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


Question: What driver IDs are not 2 from the driver list or are greater than 10 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 > 10


Question: What driver IDs are either not 10 in the driver table or 9 or less in the school bus table?

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


Question: What driver IDs are in the driver table, excluding driver ID 7 if it is also in the school bus table?

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


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


Question: What are the Driver IDs, excluding ID 3 from the driver list and ID 10 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: What is the average Aircraft ID and an example Aircraft ID for aircraft that are in both the aircraft and airport aircraft tables?

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


Question: List Driver ID 3 from the driver table and all Driver IDs greater 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: What Aircraft IDs are greater than 1 or are equal to 3?

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


Question: What are the IDs of drivers who are not driver 1 and are also school bus drivers with IDs up 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: Find driver ID 10, but not if it's a school bus driver ID greater than 10.

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


Question: What are the Driver IDs that are 10 or more in the driver list, or greater than 9 in 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 > 9


Question: What aircraft IDs are greater than 3 in the aircraft table but not greater 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: I want to find the Department ID, the count of names, the count of creation dates, and the maximum budget for departments, subject to several conditions.  First, consider departments that are either not named 'Energy', or (were not created in 1979 and don't have 109832 employees and have a budget of 6.2 billion), or (are department ID 13 and not ranked 2).  Then, from these, keep only those departments where (the count of creation dates is at least 1) or (the maximum budget is at least 46.2 billion and the count of names is at most 1).  Finally, exclude departments that are not department ID 4 and have a ranking greater than 5, and also (their maximum budget is not 58 billion or their count of names is not 1).  After applying all these conditions, what are the Department IDs and their associated counts and maximum budgets?

SELECT Department_ID, COUNT(Name), COUNT(Creation), MAX(Budget_in_Billions) FROM department WHERE Name != "Energy" OR Creation <> "1979" AND "Num_Employees" <> 109832.0 AND "Budget_in_Billions" = 6.2 OR "Department_ID" = 13 AND "Ranking" != 2 GROUP BY Department_ID HAVING COUNT(Creation) >= 1 OR MAX(Budget_in_Billions) >= 46.2 AND COUNT(Name) <= 1 EXCEPT SELECT Department_ID, COUNT(Name), COUNT(Creation), MAX(Budget_in_Billions) FROM department WHERE "Department_ID" != 4 AND "Ranking" > 5 GROUP BY Department_ID HAVING MAX(Budget_in_Billions) <> 58.0 OR COUNT(Name) != 1


Question: What driver IDs are either exactly 7 in the driver table, or 7 or greater in the school bus table?

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


Question: What source user IDs and trust values are common to relationships where the target user is not 3, and relationships where the trust is not 10 or the target user is 4 or less?

SELECT source_u_id, trust FROM trust WHERE "target_u_id" <> 3 INTERSECT SELECT source_u_id, trust FROM trust WHERE "trust" <> 10 OR "target_u_id" <= 4


Question: Which aircraft IDs are either 2 or less from the aircraft table, or 5 or more 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 drivers, other than 3, but not school bus drivers, other than 9?

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


Question: What are the Pilot, company_id, airport_id, Altitude, id, Date, and Velocity of flights that satisfy both of the following conditions: (1) they are either not on March 28, 1966, or have a low altitude, a high airport ID, and a low flight ID, or are flown by Thompson for a small company; AND (2) they have either a low velocity, a specific altitude, a low airport ID, are not on January 29, 1964, are not vehicle M2-F1 #21, are not flown by Peterson, or have a flight ID greater than 1?

Pilot company_id airport_id Altitude id Date Velocity

SELECT Pilot, company_id, airport_id, Altitude, id, Date, Velocity FROM flight WHERE Date <> "March 28, 1966" OR "Altitude" <= 3650.0 AND "airport_id" > 4 AND "id" <= 2 OR "company_id" < 5 AND Pilot = "Thompson" INTERSECT SELECT Pilot, company_id, airport_id, Altitude, id, Date, Velocity FROM flight WHERE "Velocity" <= 240.0 OR "Altitude" = 3650.0 OR "airport_id" < 5 OR Date <> "January 29, 1964" OR Vehicle_Flight_number <> "M2-F1 #21" OR Pilot <> "Peterson" OR "id" > 1


Question: What are the driver IDs that are both drivers (excluding driver ID 11) and school bus drivers (with IDs less than 9)?

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


Question: What are the unique driver IDs that are less than 11 for drivers and less than or equal to 4 for school bus drivers?

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


Question: Which aircraft IDs, other than 2, are in the aircraft table but not among aircraft IDs greater than 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: Which driver IDs are in both the driver list (excluding ID 12) and the school bus list (excluding ID 9)?

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


Question: What is Driver ID 7 from the driver table, and what are the Driver IDs other than 3 from the school bus table?

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


Question: Which aircraft IDs are in the aircraft list with IDs of 1 or greater, but are not in the airport aircraft list, ignoring aircraft ID 3 in the airport aircraft list?

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


Question: Which driver IDs under 10 are drivers but not school bus drivers, excluding driver ID 3 from the school bus drivers?

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


Question: Which aircraft IDs are in the aircraft table, other than 3, but are not among the aircraft IDs 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 are all the shipping agent codes for documents that are currently marked as 'working' and are not 'Hard Drive' type, or were received on May 31, 1996, along with the shipping agent codes from the reference list where the code is not 'AL' or the name is not 'Fedex'?

SELECT shipping_agent_code FROM Documents WHERE document_status_code = "working" AND document_type_code <> "Hard Drive" OR receipt_date = "1996-05-31 06:51:58" UNION ALL SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_code <> "AL" OR shipping_agent_name <> "Fedex"


Question: What driver IDs are both greater than 1 and also are school bus driver IDs that are 10 or less?

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: Which driver IDs are drivers, except for driver 12, but are not also school bus drivers with IDs less than 9?

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: Which driver IDs are listed in both the driver and school bus records and are number 3 or higher?

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


Question: Which driver IDs are 11 or less 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 <= 11 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 10


Question: What driver IDs are drivers, except for ID 5, and also drive school buses, except for 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 are the Club IDs for members who are either presidents, in clubs with an ID of 4 or less, or have a student ID of 1008, or have a student ID of 1007 or greater?

SELECT ClubID FROM Member_of_club WHERE Position = "President" OR "ClubID" <= 4 OR "StuID" = 1008 UNION SELECT ClubID FROM Member_of_club WHERE "StuID" >= 1007


Question: Which driver IDs from the driver table are not ID 2, and also not ID 3 if ID 3 is 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 = 3


Question: Can you list the arrival date, destination, distance, origin, airline ID, and flight number for all flights that satisfy these two conditions: first, the flight is either not from Los Angeles, or doesn't arrive at 11:10 AM on April 12, 2005, or costs less than 202.45, or is a short flight with a low flight number, or is not going to Los Angeles; and second, the flight either doesn't arrive at 3:18 AM on April 12, 2005, or departs at 7:03 AM on April 12, 2005?

arrival_date destination distance origin aid flno

SELECT arrival_date, destination, distance, origin, aid, flno FROM flight WHERE origin != "Los Angeles" OR arrival_date != "04/12/2005 11:10" OR "price" < 202.45 OR "distance" <= 1749 AND "flno" < 7 OR destination <> "Los Angeles" INTERSECT SELECT arrival_date, destination, distance, origin, aid, flno FROM flight WHERE arrival_date <> "04/12/2005 03:18" OR departure_date = "04/12/2005 07:03"


Question: What are the details and IDs of all vehicles, excluding vans with vehicle ID 2?

SELECT vehicle_details, vehicle_id FROM Vehicles WHERE vehicle_details <> "Van" OR "vehicle_id" = 3 UNION ALL SELECT vehicle_details, vehicle_id FROM Vehicles WHERE "vehicle_id" != 2


Question: What driver IDs are in both the driver list (excluding driver 4) and the school bus list (excluding driver 7)?

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


Question: What is the average employee ID for each bonus amount, excluding 3000, but only for bonus amounts awarded outside of 2011, or given to employees named Matt Stevens who are older than 23?

SELECT AVG(T1.Employee_ID), T2.Employee_ID FROM employee as T1 JOIN evaluation as T2 ON T1.Employee_ID = T2.Employee_ID WHERE "Bonus" <> 3000.0 GROUP BY Bonus HAVING Year_awarded <> "2011" OR Name = "Matt Stevens" AND Age > 23


Question: What Aircraft IDs are less than 5 from the aircraft table, or not equal to 1 from the airport_aircraft table?

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


Question: Which Aircraft IDs are both ID 3 in the aircraft table and present in the airport_aircraft table?

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


Question: What are the role code, employee name, employee ID, and other details for employees who are not in the 'ED' role, or are not named 'Erling' and not employee ID 3, or whose other details are not 'b'?

SELECT role_code, employee_name, employee_id, other_details FROM Employees WHERE role_code <> "ED" OR employee_name != "Erling" AND "employee_id" != 3 UNION ALL SELECT role_code, employee_name, employee_id, other_details FROM Employees WHERE other_details != "b"


Question: What are the driver IDs, including those that are not 3 from the driver list and those that are 3 or greater from the school bus list?

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


Question: What are the employee IDs that are in circulation history records with draft number 2 and document ID not 20, or employee ID not 2, or copy number 15, and also belong to employees who are not 'u' in other details, have role code 'ED', are not named 'Kenyon', and are not employee ID 8?

SELECT employee_id FROM Circulation_History WHERE "draft_number" = 2 AND "document_id" != 20 OR "employee_id" != 2 OR "copy_number" = 15 INTERSECT SELECT employee_id FROM Employees WHERE other_details <> "u" AND role_code = "ED" AND employee_name != "Kenyon" AND "employee_id" != 8


Question: What Aircraft IDs are in the aircraft list, excluding ID 3, but not in the airport aircraft list, excluding ID 2?

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


Question: Can you give me the customer address ID, email address, and customer ID for customers who are either not customer ID 10 or have an outstanding amount less than 1000, but exclude those who also meet either of these conditions: they are not at customer address 12, and their email is not karina.carroll@example.net, and their outstanding amount is less than 9443; or their customer ID is less than 9 and their phone number is (729)396-4354x3576?

SELECT customer_address_id, email_address, customer_id FROM Customers WHERE "customer_id" <> 10 OR "amount_outstanding" < 1000.0 EXCEPT SELECT customer_address_id, email_address, customer_id FROM Customers WHERE "customer_address_id" <> 12 AND email_address != "karina.carroll@example.net" AND "amount_outstanding" < 9443.0 OR "customer_id" < 9 AND phone_number = "(729)396-4354x3576"


Question: What driver IDs are both greater than 7 and also school bus driver IDs, excluding driver ID 9?

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


Question: Is driver ID 11 a driver but not a school bus driver?

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


Question: What are the driver IDs, excluding driver ID 4 if it is also a school bus driver?

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


Question: What are the aircraft IDs that are greater than 1 from the aircraft table, together with aircraft ID 1 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 = 1


Question: What aircraft IDs, up to 4, are in the aircraft table but not in the airport aircraft table, if we disregard aircraft ID 5 from the airport aircraft table?

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


Question: What driver IDs are there, excluding ID 2 from drivers and ID 4 from school bus drivers?

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


Question: What are the driver IDs that are 9 or less from the driver table, or less than 9 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 < 9


Question: Which drivers have an ID of 1 but are not listed as 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 <> 7


Question: What are the minimum document IDs and draft numbers from the circulation history records that meet certain criteria (being document 20, or not draft 2, or having copy number 10 or more and not employee 2), but are not among those from document drafts that meet other criteria (not 'm' draft details or not document 1)?

SELECT MIN(document_id), draft_number FROM Circulation_History WHERE "document_id" = 20 OR "draft_number" != 2 OR "copy_number" >= 10 AND "employee_id" != 2 EXCEPT SELECT MIN(document_id), draft_number FROM Document_Drafts WHERE draft_details <> "m" OR "document_id" != 1


Question: For schools that are either not school ID 4 and have a total budget percentage budgeted below 1.3, or have a total budget percentage invested of 2.0 or less, what are their total budget percentage invested, budgeted amount, total budget percentage budgeted, budget invested percentage, and school ID?

SELECT total_budget_percent_invested, Budgeted, total_budget_percent_budgeted, Budget_invested_percent, School_id FROM budget WHERE "School_id" <> 4 AND "total_budget_percent_budgeted" < 1.3 UNION SELECT total_budget_percent_invested, Budgeted, total_budget_percent_budgeted, Budget_invested_percent, School_id FROM budget WHERE "total_budget_percent_invested" <= 2.0


Question: Which driver IDs are 7 or less and are not also driver IDs greater than 9 in the school bus table?

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


Question: What are the driver IDs that are drivers, excluding driver ID 10, and are not school bus drivers with IDs 4 or less?

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


Question: What are the names of clubs that are not in France, or that started in 2011, or whose Club ID is 5 or greater?

SELECT Club_name FROM club WHERE Region <> "France" UNION SELECT Club_name FROM club WHERE "Start_year" = 2011 OR "Club_ID" >= 5


Question: What are the Driver IDs that are 10 or greater from the driver list, or are not 9 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 <> 9


Question: Which Driver IDs are 6 or less in the driver table and not greater than 10 in the school_bus table?

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


Question: List all document IDs from the Circulation History table where the document ID is 1 or less, or the employee ID is greater than 1 and the draft number is greater than 20, together with all document IDs from the Documents Mailed table where the mailed to address ID is greater than 7, or the mailing date is not May 24, 1993, or the document ID is not 4.

SELECT document_id FROM Circulation_History WHERE "document_id" <= 1 OR "employee_id" > 1 AND "draft_number" > 20 UNION ALL SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" > 7 OR mailing_date != "1993-05-24 22:13:48" OR "document_id" <> 4


Question: Which driver IDs are 8 or less from the drivers, but not greater than 7 from the school bus drivers?

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 driver IDs are greater than 3, and also driver ID 10, from the driver and school bus records?

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


Question: Which driver IDs, from 8 to 12, are also in the school bus list?

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


Question: What are the Country IDs and Continents of countries that are not in continent number 2, unless their Country ID is less than 5 and their name is not 'italy', or they are in continent number 2?

SELECT CountryId, Continent FROM countries WHERE "Continent" <> 2 EXCEPT SELECT CountryId, Continent FROM countries WHERE "CountryId" < 5 AND CountryName <> "italy" OR "Continent" = 2


Question: What aircraft IDs are 4 or higher, but not in the airport aircraft list unless that ID is 1?

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


Question: What years of working are both less than 4 years, at companies other than company 11, and for people with IDs less than 7, and also either not 2 years or for people with ID 3?

SELECT Year_working FROM employment WHERE "Year_working" < 4 AND "Company_ID" != 11 AND "People_ID" < 7 INTERSECT SELECT Year_working FROM employment WHERE "Year_working" <> 2 OR "People_ID" = 3


Question: What are the driver IDs greater than 11 from the drivers, and also driver ID 3 from the school buses?

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


Question: What Driver IDs are not 12 from the driver list, and also what Driver IDs are less than 10 from the school bus list?

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


Question: What driver IDs are in the driver table, are not 3, and are not 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 are all the continents, including every continent except 'australia', and also the continents of countries that are either not 'brazil' and have a CountryId of 6 or less, or have a continent number less than 4?

SELECT Continent FROM continents WHERE Continent <> "australia" UNION ALL SELECT Continent FROM countries WHERE CountryName <> "brazil" AND "CountryId" <= 6 OR "Continent" < 4


Question: Which driver IDs from the driver table are less than 5, except for any that are also driver ID 10 in the school bus table?

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


Question: What Driver IDs are either not 2 from the drivers, or at least 7 from the school buses?

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


Question: What are the Aircraft IDs that are 5 or less from the aircraft table, except for those that are 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 are the Driver IDs that are 10 or more from the driver list, or greater than 10 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 > 10


Question: What driver IDs are for drivers, except driver 9, but not for school bus drivers with IDs less than 10?

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


Question: What are the aircraft IDs that are in both the aircraft and airport_aircraft tables, excluding aircraft ID 2 and aircraft ID 5 respectively?

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


Question: Which driver IDs are 5 or greater in the driver table, but are not less than 3 in the school bus table?

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


Question: Which aircraft IDs are in the aircraft table, but not 2, and also not 3 if 3 is 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: What aircraft IDs from the aircraft table are 5 or less, except for ID 1 if it's also 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 driver IDs that are either greater than 8 or less than or equal to 10, considering driver IDs from both the driver list and the school bus list?

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 Aircraft IDs are listed in both the aircraft and airport aircraft databases, considering only aircraft IDs of 1 or higher from the aircraft database and aircraft IDs of 2 or lower from the airport aircraft database?

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


Question: What information do you have about Lieutenant Governors, Years, Party IDs, US Senate positions, and Governors from before 1998, or when David Paterson was Lieutenant Governor, Eliot Spitzer was Governor, and the party was Democratic, or when there was a US Senate election or someone other than Eliot Spitzer was Attorney General?

SELECT Lieutenant_Governor, Year, Party_ID, US_Senate, Governor FROM party WHERE Lieutenant_Governor = "David Paterson" AND Governor = "Eliot Spitzer" AND Party = "Democratic" OR "Year" < 1998.0 UNION SELECT Lieutenant_Governor, Year, Party_ID, US_Senate, Governor FROM party WHERE US_Senate <> "(no election)" OR Attorney_General <> "Eliot Spitzer"


Question: Which Driver IDs are 12 or more from the driver table, or are not 4 from the school bus table?

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


Question: Can you give me a list of driver IDs? Include those from the driver records that are not 5, and also include those from the school bus records that are 7 or higher.

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


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

SELECT Driver_ID FROM driver GROUP BY Driver_ID HAVING Driver_ID = 12 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 9


Question: What property type codes are there for properties that meet a complex combination of criteria based on their features, price, address, and room count?

SELECT property_type_code FROM Properties WHERE shp_feature_2 != "None" AND fld_feature_1 != "None" OR "agreed_selling_price" > 476919.3 AND property_name <> "parc east" AND date_sold <> "1973-02-24 02:56:06" AND apt_feature_1 != "consequatur" OR property_address != "2088 Bashirian Fork Suite 337 Faustinoport, MT 16771-9320" OR shp_feature_1 != "None" AND apt_feature_2 != "aut" AND fld_feature_3 <> "None" AND hse_feature_2 = "None" OR "room_count" > 2 OR oth_feature_2 != "None" INTERSECT SELECT property_type_code FROM Ref_Property_Types WHERE property_type_description <> "Shop, Retail Outlet." OR property_type_code != "House"


Question: Could you list all Aircraft IDs that are 3 or greater from the aircraft table, along with Aircraft ID 1 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 = 1


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

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


Question: Which driver IDs are drivers, other than driver ID 6, and are not among the school bus driver IDs that are less than 4?

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


Question: What are the driver IDs that are 12 from the drivers or 9 or greater from the school buses?

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


Question: What driver IDs are no more than 10 from the driver table, and also driver IDs that are greater than 3 from the school_bus table?

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


Question: What aircraft IDs are in either the aircraft table (excluding ID 2) or the airport aircraft table (excluding ID 5)?

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


Question: What are the rank, rating, a_id, and i_id for reviews that either have a rank other than 3 and an i_id of 3 or less, or have a rank other than 2 and an i_id less than 4, or have a u_id of 1?

SELECT rank, rating, a_id, i_id FROM review WHERE "rank" != 3 AND "i_id" <= 3 UNION ALL SELECT rank, rating, a_id, i_id FROM review WHERE "rank" != 2 AND "i_id" < 4 OR "u_id" = 1


Question: What are the driver IDs that are at least 3 from the driver table, or not equal to 4 from the school bus table?

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


Question: What driver IDs are both greater than 1 and not equal to 10, considering information from both the driver and school bus lists?

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 both greater than 5 and less than or equal to 10, and are listed in both the driver and school bus records?

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


Question: Could you tell me the average District ID for districts with IDs under 6, and also the average District ID for store districts excluding those with ID 15?

SELECT AVG(District_ID) FROM district WHERE "District_ID" < 6 UNION ALL SELECT AVG(District_ID) FROM store_district WHERE "District_ID" != 15


Question: What driver IDs are found in both the driver list, excluding driver 11, and the school bus driver list, excluding driver 3?

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


Question: Which driver IDs are drivers with an ID of 1 or greater, but not school bus drivers with an ID of 7 or greater?

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


Question: What driver IDs from 5 to 7 are found in both the driver and school bus lists?

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


Question: What are the average votes, sum of player names, average sponsor names, rank, earliest occupation, player ID, and latest gender for players not ranked 1st, excluding those who have 7190 votes?

SELECT AVG(Votes), SUM(Player_name), AVG(Sponsor_name), Rank, MIN(Occupation), Player_ID, MAX(Gender) FROM player WHERE Rank <> "1st" EXCEPT SELECT AVG(Votes), SUM(Player_name), AVG(Sponsor_name), Rank, MIN(Occupation), Player_ID, MAX(Gender) FROM player WHERE "Votes" = 7190


Question: What are all the Aircraft IDs, other than 2, that are in either the aircraft or airport aircraft lists?

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: Which driver ID is 7 in the driver table but not among the driver IDs greater than 9 in the school bus table?

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


Question: What aircraft IDs, other than 4, are in the aircraft table but not in the airport_aircraft table, if we ignore ID 2 in the airport_aircraft table?

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


Question: What are the aircraft IDs, excluding ID 3 and ID 5 from different 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 <> 5


Question: What are the unique Aircraft IDs that are less than 4 from the aircraft table, or less than or equal to 3 from the airport aircraft table?

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


Question: What driver ID, other than 5, is also driver ID 4 in the school bus table?

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


Question: Show me the driver IDs, including all IDs except 7, and also driver ID 9 from the school bus drivers.

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 Aircraft IDs are in both the aircraft and airport_aircraft tables, excluding ID 5 from the aircraft table and including only IDs 2 or greater 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 >= 2


Question: What driver IDs are either number 3 from the driver list or any number other than 10 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: What are the positions, club IDs, and student IDs of members who are either not a Vice-President, or not student 1007, or not in club 1, and also either student 1008 or higher, or not a President?

SELECT Position, ClubID, StuID FROM Member_of_club WHERE Position <> "Vice-President" OR "StuID" != 1007 OR "ClubID" <> 1 INTERSECT SELECT Position, ClubID, StuID FROM Member_of_club WHERE "StuID" >= 1008 OR Position <> "President"


Question: What are the Driver IDs, excluding 9 from the driver list, combined with Driver IDs greater than 4 from the school bus list?

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: Is there a branch with ID 7 that did not make any purchases in 2018 and also did not have purchases from members with ID 2 or less who spent more than 402.1 pounds, excluding branch 3?

SELECT Branch_ID FROM branch WHERE "Branch_ID" = 7 EXCEPT SELECT Branch_ID FROM purchase WHERE Year = "2018" OR "Member_ID" <= 2 AND "Total_pounds" > 402.1 AND Branch_ID != "3"


Question: What Driver IDs are 5 or greater 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 >= 5 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 4


Question: Which Driver IDs are 4 in the driver table, or not 9 in the school bus table?

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


Question: Which driver IDs are greater than 4 for drivers, but not less than 9 for school bus drivers?

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 Driver IDs are 6 or greater from the driver records, or not 4 from the school bus records?

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 less than 4 in the driver list but not greater than 10 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 > 10


Question: What Aircraft IDs are present in the aircraft table with IDs over 2, and also in the airport_aircraft table with IDs of 5 or more?

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


Question: What are the aircraft IDs that are less than 3 in the aircraft table, excluding those that are 2 or greater 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 >= 2


Question: What are the driver IDs that are ID 6 from the driver table, or any ID other than 4 from the school bus table?

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


Question: What driver ID is both greater than 3 and also equal to 4, based on the driver and school bus information?

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


Question: What are the driver IDs that are recorded in both the driver and school bus lists and are also less than 9?

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


Question: What driver IDs are 12 or more from the drivers table, or driver ID 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: What driver IDs are 9 or less in the driver table, and not greater than 4 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 > 4


Question: What Driver IDs are either 1 or less from the driver list, or greater than 3 from the school bus list?

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


Question: What Driver IDs are either 6 or less, or not 10?

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


Question: What driver IDs are in both the driver and school bus lists, excluding driver ID 3 and only considering IDs up 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: What sum of region, maximum club ID, start year, and earliest club name is the same for both clubs that are not 'Djurgårdens IF' or started in 2001 or later, and clubs that are not 'BK Häcken'?

SELECT SUM(Region), MAX(Club_ID), Start_year, MIN(Club_name) FROM club WHERE Club_name <> "Djurgårdens IF" OR "Start_year" >= 2001 INTERSECT SELECT SUM(Region), MAX(Club_ID), Start_year, MIN(Club_name) FROM club WHERE Club_name != "BK Häcken"


Question: Are there any drivers with ID 8 who are not also school bus driver number 3?

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


Question: What driver IDs are less than 3 in the driver table but not greater than 4 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 driver IDs are for drivers with IDs of 8 or more and are also for drivers with IDs greater than 4 in the school bus records?

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


Question: What aircraft IDs are exactly 2 in the aircraft table, or greater than 1 in the airport aircraft table?

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


Question: What ranks are shared between coaches who are not from club ID 3, or (not named "Smith Brown" and rank 2), or not male, or have coach ID greater than 5, and match results where (Big_Silver is less than 7, rank is not 1, and Gold is 12), or Small_Silver is not 9?

SELECT Rank FROM coach WHERE "Club_ID" <> 3 OR Coach_name != "Smith Brown" AND "Rank" = 2 OR Gender <> "M" OR "Coach_ID" > 5 INTERSECT SELECT Rank FROM match_result WHERE "Big_Silver" < 7 AND "Rank" != 1 AND "Gold" = 12 OR "Small_Silver" <> 9


Question: What are the driver IDs that are 10 or less in the driver table or 4 or more in the school bus table?

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


Question: What are all the allergies, and also include Ragweed?

SELECT Allergy FROM Allergy_Type WHERE AllergyType = "food" UNION ALL SELECT Allergy FROM Allergy_Type WHERE AllergyType <> "food" OR Allergy = "Ragweed"


Question: Which driver IDs, that are less than 4, are listed in both the driver and school bus records?

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


Question: What driver IDs are 8 or less, but not among the driver IDs less than 4 that are associated with school buses?

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 are either 1 or less, or not 4, from the drivers and school buses?

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


Question: Which driver IDs are less than 5 in the driver table but not in the school_bus table?

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


Question: What Aircraft IDs are greater than 1 in the aircraft table but not less than 3 in the airport_aircraft table?

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


Question: What driver IDs are either 12, or any ID other than 9 from the school buses?

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


Question: Which driver IDs are both not 11 and greater than 9, and are used in both the driver and school bus records?

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


Question: What driver IDs are both in the driver list (excluding driver 8) and the school bus driver list (with IDs under 4)?

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


Question: What driver IDs are less than 3 in the driver table, or equal to 10 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 = 10


Question: For the continents table, how many continents are named 'australia' and are not ContId 4? Also, for the countries table, how many continents are there that are either in countries with a CountryId of 15 or less, or are not continent 2 and are named 'russia'?

SELECT COUNT(Continent) FROM continents WHERE Continent = "australia" AND "ContId" <> 4 UNION SELECT COUNT(Continent) FROM countries WHERE "CountryId" <= 15 OR "Continent" != 2 AND CountryName = "russia"


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

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


Question: What driver IDs are 3 or greater, except for those that are 10 or less in the school bus records?

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


Question: What are the driver IDs less than 4 that are drivers but not school bus drivers, excluding school bus driver ID 4 from consideration?

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


Question: List all unique Aircraft IDs that are either from the aircraft table, excluding ID 5, or from the airport_aircraft table, but only those that are 1 or higher.

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


Question: What driver ID is common to both drivers with ID 8 or higher and school bus drivers with ID 10?

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


Question: What are the driver IDs that are on both the driver list (excluding driver ID 5) and the school bus list (only including IDs less than 10)?

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


Question: What driver IDs are greater than 3 and listed as drivers, but are not listed as school bus drivers if their ID is 4 or higher?

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 driver IDs are 8 or more in the driver table, or 10 or more 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 >= 10


Question: Which driver IDs, besides 1, are drivers but not school bus drivers with IDs greater than 4?

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


Question: What aircraft IDs are in the aircraft table with an ID of 1 or greater, but are not in the airport aircraft table with an ID of 5 or greater?

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


Question: What driver IDs, other than 2, are drivers but not also driver ID 4 in the school bus list?

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


Question: Could you list all Driver IDs, including every ID except 6 from the driver list, and also ID 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: Which driver IDs are 12 or less in the driver table, but not 9 or more in the school bus table?

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


Question: What aircraft IDs are in the aircraft table, other than 5, and are not in the airport_aircraft table if their ID is 2 or greater?

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


Question: What are the copy numbers, draft numbers, and document IDs of draft copies that are either for documents with an ID of 20 or less, or are copy number less than 4, and also are not draft number 2?

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


Question: What are the unique driver IDs that are either 10 or less, from the driver table, or 7 or more, from the school bus table?

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


Question: What driver ID is both less than 5 in the driver list and exactly 3 in the school bus list?

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 Aircraft IDs are below 4 in the aircraft table or below 2 in the airport_aircraft table?

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


Question: What driver IDs are both less than 9 and also listed as school bus drivers?

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


Question: What driver IDs are assigned to drivers, other than driver ID 11, but are not assigned to school buses with driver IDs of 9 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 >= 9


Question: What are the School IDs of schools that are either class A football schools or have an enrollment of 601 or more, but are not included in the budget information if they are not school ID 2 or meet certain budget requirements?

SELECT School_id FROM School WHERE IHSAA_Football_Class = "A" OR "Enrollment" >= 601 EXCEPT SELECT School_id FROM budget WHERE "Budgeted" >= 74849 AND "Invested" <= 140102 AND "Year" <> 2005 AND "total_budget_percent_invested" >= 2.0 AND "total_budget_percent_budgeted" != 2.0 OR "School_id" <> 2


Question: What driver IDs are 6 or less from the driver list, or 10 or more 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 >= 10


Question: What driver IDs are both greater than 6 and also equal to 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: What driver IDs less than 4 are drivers but not school bus drivers, excluding school bus driver ID 10 from consideration?

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


Question: List all aircraft IDs greater than 1, except for aircraft ID 3 if it's also found in the airport aircraft list.

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


Question: What are the smallest School IDs, one for schools that are not for junior-senior year, or have an ID less than 5, or are Punahou School, or are not Private Catholic, and another for school buses that are not for school ID 3, or are not full-time buses with experienced drivers and low Driver IDs?

SELECT MIN(School_ID) FROM school WHERE Grade <> "Junior–Senior year" OR "School_ID" < 5 OR School = "Punahou School" OR Type != "Private Catholic" UNION SELECT MIN(School_ID) FROM school_bus WHERE "School_ID" <> 3 OR If_full_time != "T" AND "Years_Working" >= 8 AND "Driver_ID" < 4


Question: Which drivers have an ID of 12 but are not listed as school bus drivers, disregarding school bus drivers with an ID of 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 are the names, football classes, counties, classes, locations, and mascots of schools that are either not named Triton, or are class AA, not in Knox, and have more than 495 students, or don't have the mascot Lions, or are not school ID 6 and not in Marshall County, or are not in football class AAA, but not including schools that are class A and don't have the mascot Jimmies?

Glenn
AAA
71 St. Joseph
AAA
Walkerton
Falcons

Jimtown
AAA
20 Elkhart
AAA
Elkhart
Jimmies

Knox Community
AAA
75 Starke
AAA
Knox
Redskins

New Prairie 1
AAAA
46 LaPorte 71 St. Joseph
AAA
New Carlisle
Cougars

SELECT School_name, IHSAA_Football_Class, County, IHSAA_Class, Location, Mascot FROM School WHERE School_name != "Triton" OR IHSAA_Class = "AA" AND Location <> "Knox" AND "Enrollment" > 495 OR Mascot != "Lions" OR School_id <> "6" AND County <> "50 Marshall" OR IHSAA_Football_Class != "AAA" EXCEPT SELECT School_name, IHSAA_Football_Class, County, IHSAA_Class, Location, Mascot FROM School WHERE Mascot != "Jimmies" AND IHSAA_Football_Class = "A"


Question: What are driver ID 1 from the driver table and driver ID 10 from the school bus table?

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


Question: On March 9, 2018 at 7:03 PM, how many area codes are associated with states that had votes?

SELECT COUNT(T1.area_code), T2.created FROM AREA_CODE_STATE as T1 JOIN VOTES as T2 ON T1.state = T2.state WHERE created = "2018-03-09 19:03:39"


Question: Which driver IDs are 3 or greater, excluding driver ID 9 if it is also listed for a school bus?

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


Question: What aircraft IDs, other than 4, are in the aircraft table but not in the airport aircraft table, considering only airport aircraft IDs up to 3?

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


Question: What driver IDs are 9 or greater in the driver list but not 7 or greater in the school bus list?

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


Question: What are the Driver IDs that are both in the driver and school bus lists, are 10 or less, but not 3?

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


Question: What are the Club IDs for clubs that are not ID 1, or clubs that are not named 'Gefle IF', started after 2000, and are not in the UK? Also, include Club IDs for coaches who are coach ID 5, female, or rank 4 or higher.

SELECT Club_ID FROM club WHERE "Club_ID" <> 1 OR Club_name != "Gefle IF" AND "Start_year" > 2000 AND Region != "UK" UNION SELECT Club_ID FROM coach WHERE "Coach_ID" = 5 OR Gender != "M" OR "Rank" >= 4


Question: What is the total sum of region values for clubs that are either not named 'Djurgårdens IF' and started in 2005 or later, or not in the USA, or have a Club ID greater than 3, or started in 2000 or earlier and are in the USA?

SELECT SUM(Region) FROM club WHERE Club_name <> "Djurgårdens IF" AND "Start_year" >= 2005 OR Region <> "USA" OR "Club_ID" > 3 UNION ALL SELECT SUM(Region) FROM club WHERE "Start_year" <= 2000 AND Region = "USA"


Question: Which driver IDs less than 12 are drivers but not school bus drivers with IDs of 3 or less?

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


Question: What driver IDs are greater than 4 in the driver table, or less than 7 in the school bus table?

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


Question: What driver IDs under 7 are drivers but not school bus drivers, excluding school bus driver 4?

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


Question: What are the driver IDs that are both not 5 and at least 4?

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


Question: What driver IDs from the driver table are not 4 and not 5?

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


Question: What driver IDs are both 4 or greater and also greater than 9?

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


Question: What is the Aircraft ID that is both less than 3 in the aircraft table and equal to 2 in the airport aircraft table?

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: Which driver IDs, other than 2, are drivers but not school bus drivers, considering only school bus drivers other than 9?

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


Question: What are the aircraft IDs that are in the aircraft table, are not 3, and are not among the aircraft IDs 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 are the driver IDs of drivers who are not driver 11, and are also not school bus drivers with IDs of 4 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 >= 4


Question: What driver IDs are drivers, other than 7, but not school bus drivers, other than 9?

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


Question: What are all driver IDs except 1, and also not 3 if 3 is a school bus driver?

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: Could you provide a list of IDs, including flight IDs for high altitude flights, flights not from airport 6, flights piloted by Thompson, or flights with specific date, ID, and vehicle number characteristics, and also operating company IDs for companies not named Dragonair Holidays, companies with specific type, ID, incorporation, and activity characteristics, or companies without 100% group equity shareholding?

SELECT id FROM flight WHERE "Altitude" >= 3650.0 OR "airport_id" != 6 OR Pilot = "Thompson" OR Date != "October 25, 1963" AND "id" != 6 AND Vehicle_Flight_number <> "M2-F1 #39" UNION ALL SELECT id FROM operate_company WHERE name != "Dragonair Holidays" OR Type <> "Joint Venture" AND "id" > 8 AND Incorporated_in != "Canada" AND Principal_activities = "Travel agency" OR "Group_Equity_Shareholding" != 100.0


Question: What are the descriptions and codes of document statuses that are neither 'working' nor 'mailed late'?

SELECT document_status_description, document_status_code FROM Ref_Document_Status WHERE document_status_code != "working" INTERSECT SELECT document_status_description, document_status_code FROM Ref_Document_Status WHERE document_status_description <> "mailed late"


Question: List all unique Driver IDs that are less than 4 from the driver table and less than or equal to 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: Could you give me two numbers: first, the count of coaches from the coach table who are either named Jameson Tomas and female, or associated with Club ID 1 or higher; and second, the count of coaches from the player_coach table who either have Coach ID 2, Player ID 14 or higher, or a starting year before 2013?

SELECT COUNT(Coach_ID) FROM coach WHERE Coach_name = "Jameson Tomas" AND Gender = "F" OR "Club_ID" >= 1 UNION ALL SELECT COUNT(Coach_ID) FROM player_coach WHERE "Coach_ID" = 2 OR "Player_ID" >= 14 OR "Starting_year" < 2013


Question: List aircraft ID 2 from the aircraft table and all aircraft IDs except 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 Aircraft IDs, other than 1, are found in both the aircraft and airport aircraft lists?

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


Question: What driver IDs are both not equal to 4 in the driver list and greater than 7 in the school bus driver list?

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


Question: What are the aircraft IDs that are less than 2 in the aircraft table but not also less than 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 employee IDs are either '7' from the evaluation records or belong to part-time employees hired outside of 2008 and working in shops with an ID greater than 2?

SELECT Employee_ID FROM evaluation WHERE Employee_ID = "7" UNION SELECT Employee_ID FROM hiring WHERE Is_full_time <> "T" AND Start_from != "2008" AND "Employee_ID" >= 1 AND "Shop_ID" > 2


Question: What driver IDs, besides 11 and 7, are in the driver or school bus records?

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: For each IHSAA class, what are the enrollment and invested amounts for classes that contain schools meeting any of these criteria: school name is 'Glenn' and enrollment is below 495, budget invested percentage is not 42.9, or county is '71 St. Joseph'?

SELECT T1.Enrollment, T2.Invested FROM School as T1 JOIN budget as T2 ON T1.School_id == T2.School_id GROUP BY IHSAA_Class HAVING Enrollment < 495 AND School_name = "Glenn" OR Budget_invested_percent <> "42.9" OR County = "71 St. Joseph"


Question: What are the driver IDs that are both greater than 8 and less than 10, and appear in both the driver and school bus lists?

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


Question: What Driver IDs are listed in both the driver and school bus records and are number 3 or higher?

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


Question: What aircraft IDs are less than or equal to 3 in the aircraft table but not less than or equal to 2 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 <= 2


Question: What Aircraft IDs are in both the aircraft table (excluding ID 4) and the airport aircraft table (excluding ID 5)?

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: Which driver IDs are not 2, or are greater than 10 in the school bus records?

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 aircraft IDs are 4 or less in the aircraft table, but not aircraft ID 2 from the airport_aircraft table?

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


Question: Which driver IDs, that are 1 or greater, are in the driver table but not driver ID 9 if it's in the school bus table?

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


Question: What driver IDs are either number 6 from the drivers or not number 7 from the 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 are the driver IDs, other than 2, that are drivers but not school bus drivers with IDs less than 10?

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


Question: Which Book IDs are published by someone other than Bertelsmann and also meet at least one of these conditions: either the Book ID is less than 3, or they are from Pearson, not published in June 2006, and cost 3 million or more?

SELECT Book_ID FROM publication WHERE Publisher <> "Bertelsmann" INTERSECT SELECT Book_ID FROM publication WHERE "Book_ID" < 3 OR Publisher = "Pearson" AND Publication_Date <> "June 2006" AND "Price" >= 3000000.0


Question: What are the document IDs for documents that are not hard drives or have 'p' as other details, as well as for mailed documents not sent to address ID 2?

SELECT document_id FROM Documents WHERE document_type_code <> "Hard Drive" OR other_details = "p" UNION ALL SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" != 2


Question: Which driver IDs are 2 or greater, except for driver ID 3 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 = 3


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

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


Question: What are the Driver IDs from the driver table, excluding driver ID 3, and from the school bus table, excluding driver ID 10?

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: What are the Major, city code, and Advisor for students who meet certain criteria, excluding those who meet other criteria? Include students if their Major is less than 100, or their first name is Tracy, or they satisfy a specific combination of ID, gender, and last name, or a combination of city, age, and advisor. However, exclude students if their last name is Lee, or if they are male and their Major is 600 or less.

SELECT Major, city_code, Advisor FROM Student WHERE "Major" < 100 OR Fname = "Tracy" OR "StuID" <> 1003 AND Sex != "F" AND LName = "Apap" OR city_code <> "WAS" AND "Age" = 18 AND "Advisor" >= 2192 EXCEPT SELECT Major, city_code, Advisor FROM Student WHERE LName = "Lee" OR "Major" <= 600 AND Sex = "M"


Question: What are the number of stores in each district for districts with ID 15 or higher, or stores with ID 4 or lower, as well as for stores with ID 3?

SELECT District_ID, COUNT(Store_ID) FROM store_district WHERE "District_ID" >= 15 OR "Store_ID" <= 4 UNION SELECT District_ID, COUNT(Store_ID) FROM store_district WHERE "Store_ID" = 3


Question: What are the gender, rank, club ID, and coach ID for coaches who either have a Coach ID greater than 1, or are not Coach ID 3 and not named Jameson Tomas, or are not male, or have a rank greater than 1?

SELECT Gender, Rank, Club_ID, Coach_ID FROM coach WHERE "Coach_ID" > 1 UNION SELECT Gender, Rank, Club_ID, Coach_ID FROM coach WHERE "Coach_ID" != 3 AND Coach_name != "Jameson Tomas" OR Gender <> "M" OR "Rank" > 1


Question: Could you list the mailed address ID and document ID for documents that have a document ID of 12 or more, or were not mailed on the morning of November 4, 2010, or have a document ID greater than 14?

SELECT mailed_to_address_id, document_id FROM Documents_Mailed WHERE "document_id" >= 12 UNION ALL SELECT mailed_to_address_id, document_id FROM Documents_Mailed WHERE mailing_date <> "2010-11-04 04:00:16" OR "document_id" > 14


Question: What are the IDs of airports that are in Barcelona, or not named 'National Airport', or with an ICAO code other than 'KBWI', or an IATA code other than 'BOS', or with an ID of 7 or more? And also, what are the IDs of flights that have an altitude less than 3650, or a flight number of 'M2-F1 #33', or an airport ID less than 5?

SELECT id FROM airport WHERE City = "Barcelona" OR name <> "National Airport" OR ICAO != "KBWI" OR IATA <> "BOS" OR "id" >= 7 UNION ALL SELECT id FROM flight WHERE "Altitude" < 3650.0 OR Vehicle_Flight_number = "M2-F1 #33" OR "airport_id" < 5


Question: What are the Aircraft IDs that are in both the aircraft and airport aircraft lists and are 3 or less?

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


Question: List the Aircraft IDs that are greater than 1 from the aircraft table, excluding those Aircraft IDs less than 3 from the airport_aircraft table.

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


Question: What driver IDs are both 10 or less and also equal to 3?

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


Question: Could you list the name and code for shipping agents that are either coded 'UP', or named 'USPS' and not described as 'k', or described as 't', or not coded 'SH' and named 'Fedex'?

SELECT shipping_agent_name, shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_code = "UP" OR shipping_agent_name = "USPS" AND shipping_agent_description <> "k" UNION ALL SELECT shipping_agent_name, shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_description = "t" OR shipping_agent_code <> "SH" AND shipping_agent_name = "Fedex"


Question: What are the driver IDs that are either less than 9 from the driver list or at least 7 from the school bus list?

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


Question: What are the driver IDs that are not 5 from the driver list, and also driver ID 4 from the school bus list?

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


Question: What are the Driver IDs that are at least 5, or are not 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: For each maximum gross weight, what are the counts of descriptions, aircraft IDs, total disk areas, and aircraft, considering two different sets of criteria for aircraft and combining the results?

SELECT COUNT(Description), COUNT(Aircraft_ID), COUNT(Total_disk_area), COUNT(Aircraft), Max_Gross_Weight FROM aircraft WHERE Max_Gross_Weight = "3,200 lb (1,451 kg)" AND Max_disk_Loading != "3.7 lb/ft² (18 kg/m²)" AND "Aircraft_ID" <> 5 OR Total_disk_area != "5,655 ft² (526 m²)" GROUP BY Max_Gross_Weight HAVING COUNT(Aircraft) < 1 OR COUNT(Total_disk_area) > 1 OR COUNT(Aircraft_ID) >= 1 UNION SELECT COUNT(Description), COUNT(Aircraft_ID), COUNT(Total_disk_area), COUNT(Aircraft), Max_Gross_Weight FROM aircraft WHERE "Aircraft_ID" >= 5 AND Max_Gross_Weight != "123,500 lb (56,000 kg)" OR Description = "Tandem rotor helicopter" OR Aircraft != "Robinson R-22" OR Total_disk_area = "872 ft² (81.1 m²)" OR Max_disk_Loading <> "8.8 lb/ft² (43 kg/m²)" GROUP BY Max_Gross_Weight HAVING COUNT(Description) < 1


Question: Which drivers, other than driver ID 9, are not also school bus drivers, excluding school bus driver ID 3 from the school bus driver list?

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


Question: What are all the driver IDs, other than 9, that are listed in either the driver or school bus information?

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


Question: What driver IDs are both greater than 2 and less than 10, and 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 < 10


Question: What are the role codes for employees who are not part-time or whose other details are not 'u', as well as the role codes for roles that are not manager roles?

SELECT role_code FROM Employees WHERE role_code != "PT" OR other_details <> "u" UNION ALL SELECT role_code FROM Roles WHERE role_description != "Manager"


Question: What are the player IDs of players who are either not male or have at least 2353 votes, and are also coached by someone other than coach number 1?

SELECT Player_ID FROM player WHERE Gender <> "M" OR "Votes" >= 2353 INTERSECT SELECT Player_ID FROM player_coach WHERE "Coach_ID" != 1


Question: What driver IDs are assigned to both drivers with an ID of 3 or higher and school bus drivers, excluding driver ID 10?

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


Question: What are the average allergy type, excluding food, and the average allergy type, excluding animal but including grass pollen?

SELECT AVG(AllergyType) FROM Allergy_Type WHERE AllergyType <> "food" UNION ALL SELECT AVG(AllergyType) FROM Allergy_Type WHERE AllergyType <> "animal" OR Allergy = "Grass Pollen"


Question: Which driver IDs are both greater than 6 and not equal to 9, and are present in both the driver and school bus records?

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: What are the unique Aircraft IDs that are either less than 1 in the aircraft table or less than 3 in the airport_aircraft table?

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


Question: What are the Driver IDs that are either less than 10 or greater than 4, considering driver and school bus information?

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


Question: Which aircraft IDs, other than 4, are in the aircraft table but not in the airport aircraft table if we only consider IDs greater than 5 there?

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


Question: Give me all Driver IDs that are not 4 from the driver table, or are less than 3 from the school_bus table.

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


Question: Which driver IDs are in both the driver list (where IDs are 11 or less) and the school bus list (where IDs are not 10)?

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