Question: What are the transit passenger numbers and the number of associated aircraft for each airport?

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


Question: Show me driver ID 11, and all driver IDs except 4 from the school bus list.

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


Question: What are the names and IDs of aircraft that either have a distance of 1805, are named 'Piper Archer III', are not named 'Boeing 727', or have an ID other than 2 and a distance of 3383 or less?

SELECT name, aid FROM aircraft WHERE "distance" = 1805 OR name = "Piper Archer III" UNION ALL SELECT name, aid FROM aircraft WHERE name != "Boeing 727" OR "aid" != 2 AND "distance" <= 3383


Question: Excluding the highest Company ID from employment records with more than 3 people and not Company ID 15, what is the highest Company ID from companies that are either named 'Berkshire Hathaway', are not headquartered in the USA, have sales not equal to 87.6 billion, and are not in the banking industry, or have a Company ID less than 9 and assets greater than 209.5 billion?

SELECT MAX(Company_ID) FROM company WHERE "Sales_in_Billion" != 87.6 AND Headquarters <> "USA" AND Name = "Berkshire Hathaway" AND Industry != "Banking" OR "Company_ID" < 9.0 AND "Assets_in_Billion" > 209.5 EXCEPT SELECT MAX(Company_ID) FROM employment WHERE "People_ID" > 3 AND "Company_ID" != 15


Question: What aircraft IDs, that are 4 or greater, are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 1 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 <> 1


Question: What are the countries of addresses that are either not at "37698 Hahn Curve Apt. 572", or are in Idaho but not the USA, or have an address ID of 2 or less and zip code "61121", or are not in Port Melyssa with zip code "27559" and address ID greater than 10, or are not in the USA and not in West Virginia?

SELECT country FROM Addresses WHERE line_1_number_building != "37698 Hahn Curve Apt. 572" OR country != "USA" AND state_province_county = "Idaho" OR "address_id" <= 2 AND zip_postcode = "61121" UNION ALL SELECT country FROM Addresses WHERE city <> "Port Melyssa" AND zip_postcode = "27559" AND "address_id" > 10 OR country != "USA" AND state_province_county <> "WestVirginia"


Question: What's the average AllergyType for allergies that are not eggs, and also for allergies that are soy or environmental?

SELECT Allergy, AVG(AllergyType) FROM Allergy_Type WHERE Allergy != "Eggs" UNION SELECT Allergy, AVG(AllergyType) FROM Allergy_Type WHERE Allergy = "Soy" OR AllergyType = "environmental"


Question: What are the ID, maximum IATA, country, city, name, and maximum ICAO for airports that are either 'Akureyri Airport' in Baltimore, not 'ENBR', and with an ID less than 7, or that are not in Iceland, or have IATA 'BGO', or are not 'Bergen Airport', or are ID 7, not in Baltimore, and not 'ENBR'?

id MAX(IATA) Country SUM(City) name MAX(ICAO)

3.0
BWI
United States
0.0
Ted Stevens Airport
PANC

SELECT id, MAX(IATA), Country, SUM(City), name, MAX(ICAO) FROM airport WHERE ICAO != "ENBR" AND name = "Akureyri Airport" AND City = "Baltimore" AND "id" < 7 UNION SELECT id, MAX(IATA), Country, SUM(City), name, MAX(ICAO) FROM airport WHERE Country != "Iceland" OR IATA = "BGO" OR name <> "Bergen Airport" OR "id" = 7 AND City <> "Baltimore" AND ICAO != "ENBR"


Question: What are the highest role description and role code, both when excluding roles with the code 'PT', and separately when excluding roles described as 'Manager'?

SELECT MAX(role_description), MAX(role_code) FROM Roles WHERE role_code != "PT" UNION SELECT MAX(role_description), MAX(role_code) FROM Roles WHERE role_description != "Manager"


Question: Which driver IDs are either 1 or less, or not 10, from both 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 <> 10


Question: What's the smallest ID that is shared between car makers (excluding ID 3 and Volvo) and cars meeting specific criteria?

SELECT MIN(Id) FROM car_makers WHERE "Id" <> 3 AND FullName <> "Volvo" INTERSECT SELECT MIN(Id) FROM cars_data WHERE "Weight" = 2945 OR "Accelerate" != 12.1 OR "Edispl" >= 258.0 AND "Id" <> 17 AND MPG = "28"


Question: What are the Aircraft IDs that are 1 or higher in the aircraft table, or different from 1 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 <> 1


Question: Could you list the descriptions and maximum gross weights for aircraft that are either CH-53E Super Stallions (excluding those with a max disk loading of 2.6 lb/ft² and max gross weight of 3,200 lb), or have an Aircraft ID of 5 and a total disk area of 4,900 ft², or have a total disk area of 4,900 ft² but not a max gross weight of 73,500 lb?

Heavy-lift helicopter
73,500 lb (33,300 kg)

SELECT Description, Max_Gross_Weight FROM aircraft WHERE Max_disk_Loading <> "2.6 lb/ft² (14 kg/m²)" AND Max_Gross_Weight <> "3,200 lb (1,451 kg)" AND Aircraft = "CH-53E Super Stallion" OR "Aircraft_ID" = 5 AND Total_disk_area = "4,900 ft² (460 m²)" UNION ALL SELECT Description, Max_Gross_Weight FROM aircraft WHERE Max_Gross_Weight != "73,500 lb (33,300 kg)" AND Total_disk_area = "4,900 ft² (460 m²)"


Question: Are there any driver IDs that are 8, and are not among the school bus driver IDs that are 4 or less?

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 aircraft IDs are in both the aircraft and airport aircraft tables, but not 1 or 3?

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


Question: What aircraft IDs less than 4 from the aircraft table are not in the airport_aircraft table, if we ignore aircraft 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: Which Aircraft IDs less than 2 are in the aircraft table but not 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 >= 5


Question: What are the document IDs for documents mailed on January 1, 2007 at 10:32 PM or to address ID 8, combined with the document IDs for draft copies that are draft number 17 or have a document ID of 1 or greater and copy number 10?

SELECT document_id FROM Documents_Mailed WHERE mailing_date = "2007-01-01 22:32:11" OR "mailed_to_address_id" = 8 UNION SELECT document_id FROM Draft_Copies WHERE "draft_number" = 17 OR "document_id" >= 1 AND "copy_number" = 10


Question: What are the Club ID, Coach name, Gender, and Coach ID of female coaches who are either not Coach ID 3 or have a rank other than 1?

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


Question: What are the Driver IDs that are greater than 10 from the drivers and also the Driver IDs that are 4 or less from the school buses?

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


Question: What is the total number of genders for coaches, excluding 'James Wong' and Coach ID 2, and for players sponsored by 'Selkirk—Interlake' who meet specific criteria on their occupation, rank, ID, residence, or name?

SELECT COUNT(Gender) FROM coach WHERE Coach_name <> "James Wong" AND "Coach_ID" <> 2 UNION ALL SELECT COUNT(Gender) FROM player WHERE Sponsor_name = "Selkirk—Interlake" AND Occupation <> "Ministerial Assistant" AND Rank <> "1st" AND "Player_ID" >= 14 AND Residence != "Winnipeg" OR Player_name <> "Judy Wasylycia-Leis"


Question: Show me the Club ID and Club Name for clubs that are not located in AKW, or are located in HHH, or are named 'Bootup Baltimore', or have an ID other than 3, or whose description is 'Venture capital fund for student business' or 'Play pen and paper games on campus'.

SELECT ClubID, ClubName FROM Club WHERE ClubLocation <> "AKW" OR ClubName = "Bootup Baltimore" OR "ClubID" <> 3 OR ClubDesc = "Venture capital fund for student business." UNION SELECT ClubID, ClubName FROM Club WHERE ClubLocation = "HHH" OR ClubDesc = "Play pen and paper games on campus."


Question: What are the product IDs that are 3 or less, or equal to 1?

SELECT Product_ID FROM store_product WHERE "Product_ID" <= 3 UNION SELECT Product_ID FROM store_product WHERE "Product_ID" = 1


Question: What are the driver IDs that are less than 4 or not equal to 4 in the school bus list?

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


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

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 driver IDs are common between drivers who are not driver 1 and school bus drivers who are driver 9?

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


Question: What driver IDs are in both the driver table (excluding driver ID 4) and the school_bus table (excluding driver ID 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: Could you list the contestant number, vote ID, creation date and time, and state for votes where either the contestant number is greater than 3 or the phone number is 6209222712 or less, or the vote was created on '2018-03-09 19:03:36' or the vote ID is not 3?

SELECT contestant_number, vote_id, created, state FROM VOTES WHERE "contestant_number" > 3 OR "phone_number" <= 6209222712 UNION SELECT contestant_number, vote_id, created, state FROM VOTES WHERE created = "2018-03-09 19:03:36" OR "vote_id" <> 3


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

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


Question: What driver IDs are there, excluding driver ID 2 from the drivers and driver ID 4 from the 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 Aircraft IDs that are 1 or less and are recorded 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 <= 3


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


Question: What driver IDs, other than 1, are listed as drivers but not as school bus drivers, considering only school bus drivers who are not ID 10?

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


Question: What are the Party IDs and Comptrollers for parties where either the Attorney General is not Andrew Cuomo, or the Lieutenant Governor is not Dennis Mehiel and the party is not 'Working Families' and US Senate is '(no election)' and Governor is not Eliot Spitzer, or the Party ID is less than 2, or the year is not 1998, or the Lieutenant Governor is not David Paterson, or the US Senate is not Hillary Rodham Clinton and the Attorney General is not Andrew Cuomo, or the party is not 'Independence' and the Governor is not Carl McCall?

SELECT Party_ID, Comptroller FROM party WHERE Attorney_General != "Andrew Cuomo" OR Lieutenant_Governor != "Dennis Mehiel" AND Party <> "Working Families" AND US_Senate = "(no election)" AND Governor != "Eliot Spitzer" AND "Party_ID" < 2 OR "Year" <> 1998.0 UNION ALL SELECT Party_ID, Comptroller FROM party WHERE Lieutenant_Governor <> "David Paterson" OR US_Senate != "Hillary Rodham Clinton" AND Attorney_General <> "Andrew Cuomo" OR Party <> "Independence" AND Governor != "Carl McCall"


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

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


Question: Which driver IDs under 8 are drivers but not 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 is the earliest publication date, the highest price, and the publisher for publications that are either not from 'Thomson Reuters', have a 'Book_ID' other than 9, and were published in 'April 2007', or have a 'Price' less than 6 million; or have a 'Publication_ID' less than 1, or have a 'Price' of 3 million or more and are not from 'Bertelsmann'?

SELECT MIN(Publication_Date), MAX(Price), Publisher FROM publication WHERE Publisher <> "Thomson Reuters" AND "Book_ID" <> 9 AND Publication_Date = "April 2007" OR "Price" < 6000000.0 UNION ALL SELECT MIN(Publication_Date), MAX(Price), Publisher FROM publication WHERE "Publication_ID" < 1 OR "Price" >= 3000000.0 AND Publisher <> "Bertelsmann"


Question: What aircraft IDs, other than 3, are in the aircraft table but not in the airport aircraft table for IDs 2 or higher?

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 number 2 in the aircraft table but not number 1 or less 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: Are there any drivers with ID 8 who are not also drivers with IDs less than 4 in the school bus records?

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: For departments that are either ranked 5 and not named 'State', or have a budget other than 62.8 billion, or have a number of employees different from 17347, and also have at least one creation entry, OR departments that were created in 1789 and not named 'Energy', or have 58622 employees, and whose total budget is not 11.1 billion and the number of creation entries is not exactly one, what are the Department IDs, along with the count of creations and the total budget for each of these departments?

SELECT Department_ID, COUNT(Creation), SUM(Budget_in_Billions) FROM department WHERE "Ranking" = 5 AND Name != "State" OR "Budget_in_Billions" <> 62.8 OR "Num_Employees" != 17347.0 GROUP BY Department_ID HAVING COUNT(Creation) >= 1 UNION SELECT Department_ID, COUNT(Creation), SUM(Budget_in_Billions) FROM department WHERE Creation = "1789" AND Name != "Energy" OR "Num_Employees" = 58622.0 GROUP BY Department_ID HAVING SUM(Budget_in_Billions) != 11.1 AND COUNT(Creation) != 1


Question: What are aircraft ID 4 from the aircraft table, and aircraft IDs other than 2 from the airport aircraft table?

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


Question: What are the IDs of clubs that are not described as 'Refurbish computers; teach kids and adults about computer basics', or clubs that have members with student IDs greater than 1001 who are not presidents?

SELECT ClubID FROM Club WHERE ClubDesc != "Refurbish computers; teach kids and adults about computer basics." UNION ALL SELECT ClubID FROM Member_of_club WHERE "StuID" > 1001 AND Position != "President"


Question: Is there a driver with ID 11 who is not also a school bus driver with an ID of 9 or less?

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: Which Aircraft IDs are greater than 3 in the aircraft table, but are not also Aircraft IDs of 5 or more 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 IDs of drivers who are drivers but not school bus drivers, excluding driver ID 9?

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


Question: What are the names of all feature types other than 'Amenity, eg Pool.'?

SELECT feature_type_name FROM Ref_Feature_Types WHERE feature_type_code != "Amenity" AND feature_type_name != "Amenity, eg Pool." UNION ALL SELECT feature_type_name FROM Ref_Feature_Types WHERE feature_type_name <> "Amenity, eg Pool."


Question: What is the ID of aircraft number 4, excluding those that are also numbered 1 or less in the airport airport aircraft 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 <= 1


Question: What is the smallest Member ID for a member who either has card number 'LCB7', or is not from Fort Campbell, Kentucky, is level 4 or higher, and is not member 9, unless that ID is also the smallest Member ID for members in branch '6' (excluding member 8) in the membership register branch table?

SELECT MIN(Member_ID) FROM member WHERE Card_Number = "LCB7" OR Hometown <> "Fort Campbell, Kentucky" AND "Level" >= 4 AND "Member_ID" <> 9 EXCEPT SELECT MIN(Member_ID) FROM membership_register_branch WHERE "Member_ID" <> 8 AND Branch_ID = "6"


Question: What Aircraft IDs are both less than 3 and not equal to 1, and are found in both the aircraft and airport aircraft data?

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 are the lowest draft number and highest document ID for circulation history entries with draft numbers no more than 1, as well as for document drafts that are not marked with 'k'?

SELECT MIN(draft_number), MAX(document_id) FROM Circulation_History WHERE "draft_number" <= 1 UNION ALL SELECT MIN(draft_number), MAX(document_id) FROM Document_Drafts WHERE draft_details <> "k"


Question: Which driver IDs in the driver table are less than 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 = 7


Question: What are the aircraft IDs that are less than 5 in the aircraft table, but not less than 1 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 counts and titles for items with ID 5 and for items with the title 'comb'?

SELECT COUNT(i_id), title FROM item WHERE "i_id" = 5 UNION ALL SELECT COUNT(i_id), title FROM item WHERE title = "comb"


Question: What are the driver IDs from 1 to 9 that are drivers but not school bus drivers, excluding school bus driver ID 9?

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


Question: What are the driver IDs that are greater than 7 and are listed in both the driver and school bus records?

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 are the student IDs for club members who are either student 1010 or not a Teaching Coordinator, as well as the student IDs for female students named Eric who are not from PIT?

SELECT StuID FROM Member_of_club WHERE "StuID" = 1010 OR Position != "Teaching Coordinator" UNION ALL SELECT StuID FROM Student WHERE city_code != "PIT" AND Sex <> "M" AND Fname = "Eric"


Question: What are all driver IDs besides 1, and also include driver ID 10 if it's a school bus driver ID?

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


Question: What is the smallest student ID of a student with a shellfish allergy, unless that ID is also the smallest ID of a student who is advised by advisor 2311 or higher and lives in Boston, or whose last name is Prater?

SELECT MIN(StuID) FROM Has_Allergy WHERE Allergy = "Shellfish" EXCEPT SELECT MIN(StuID) FROM Student WHERE "Advisor" >= 2311 AND city_code = "BOS" OR LName = "Prater"


Question: What are the driver IDs, other than 10, that are in the driver table but not in the school bus table as driver ID 7?

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


Question: What are the Driver IDs, other than driver ID 1 for drivers and driver ID 4 for 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: What are the driver IDs, considering IDs less than 3 from the driver list and IDs 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: Could you list all names, including repetitions, of employees who are not Jason Hobson, or are either not from Leicester and 40 or younger, or have an employee ID of 7 or less, and also include the names of shops that are not in Mariehamn, or are not managed by Mika Laurikainen, or are not in the Finnair Stadium district?

SELECT Name FROM employee WHERE Name != "Jason Hobson" OR City != "Leicester" AND "Age" <= 40 OR "Employee_ID" <= 7 UNION ALL SELECT Name FROM shop WHERE Location != "Mariehamn" OR Manager_name != "Mika Laurikainen" OR District <> "Finnair Stadium"


Question: Show me all names that are either from branches that are not named Stanley, were not opened in 2015, and have a Branch ID of 4 or more, or are located on Valleys Place and have a membership amount of 11; or from members who have card number RCB32, are not from Red Jacket, West Virginia, and are not named Myron Pryor.

SELECT Name FROM branch WHERE Name <> "Stanley" AND Open_year <> "2015" AND "Branch_ID" >= 4 OR Address_road = "Valleys Place" AND membership_amount = "11" UNION SELECT Name FROM member WHERE Card_Number = "RCB32" AND Hometown <> "Red Jacket, West Virginia" AND Name != "Myron Pryor"


Question: Which Driver IDs are less than 1 in the driver table, and which Driver IDs are 3 or greater in the school bus table?

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


Question: Which driver IDs are less than 6, excluding any that are also driver ID 7 in the school bus records?

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


Question: What Aircraft IDs are both greater than 4 and not 1, and are found in both the aircraft and airport aircraft lists?

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: Tell me if student 1022 is listed as having an allergy other than shellfish, or if their student ID is 1003 or less, in the allergy records.

SELECT StuID FROM Has_Allergy WHERE "StuID" <= 1003 OR Allergy <> "Shellfish" INTERSECT SELECT StuID FROM Student WHERE "StuID" = 1022


Question: What is the combined sum of District IDs from 'district' for 'Chiniot District' with city area over 38.0 and not ID 8, and from 'store_district' where District ID is not 15 or Store ID is over 4?

SELECT SUM(District_ID) FROM district WHERE "City_Area" > 38.0 AND "District_ID" != 8 AND District_name = "Chiniot District" UNION ALL SELECT SUM(District_ID) FROM store_district WHERE "District_ID" <> 15 OR "Store_ID" > 4


Question: Can you tell me the names of shops that are either not named 'FC KooTeePee' and in 'Tehtaan kenttä', or in 'Valkeakoski', or have more than 3500 products, or are shop 5 managed by 'Mika Lehkosuo', or are not named 'HJK' and not shop 5, or don't have 1600 products, or are neither in 'Helsinki' nor in 'Magnum Areena' district?

SELECT Name FROM shop WHERE Name <> "FC KooTeePee" AND District = "Tehtaan kenttä" OR Location = "Valkeakoski" OR "Number_products" > 3500 OR "Shop_ID" = 5 AND Manager_name = "Mika Lehkosuo" UNION ALL SELECT Name FROM shop WHERE Name <> "HJK" AND "Shop_ID" != 5 OR "Number_products" <> 1600 OR Location != "Helsinki" AND District <> "Magnum Areena"


Question: Could you list the Employee IDs of employees who received a bonus of 3200 or less, or a bonus in any year except 2016, but are not also employees who work in shop ID 6 or less, or are not employee ID 6, or started work in any year except 2008, or are not full-time?

SELECT Employee_ID FROM evaluation WHERE "Bonus" <= 3200.0 OR Year_awarded != "2016" EXCEPT SELECT Employee_ID FROM hiring WHERE "Shop_ID" <= 6 OR "Employee_ID" <> 6 OR Start_from != "2008" OR Is_full_time <> "T"


Question: What are the coach IDs and the sum of starting years in two cases: one where player ID is not 14, coach ID is not 3, or starting year is 2012 or later, and another where starting year is before 2011?

SELECT Coach_ID, SUM(Starting_year) FROM player_coach WHERE "Player_ID" <> 14 OR "Coach_ID" != 3 OR "Starting_year" >= 2012 UNION ALL SELECT Coach_ID, SUM(Starting_year) FROM player_coach WHERE "Starting_year" < 2011


Question: What driver IDs are common to drivers with IDs up to 12 and school bus drivers, excluding ID 10?

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


Question: What car makers are from country '1' or make model ID 25?

SELECT Maker FROM car_makers WHERE Country = "1" UNION SELECT Maker FROM model_list WHERE "ModelId" = 25


Question: What driver IDs are less than 12 in the driver table but not greater than 7 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 > 7


Question: What driver IDs are both in the group of drivers with IDs up to 9, and in the group of school bus drivers excluding ID 4?

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


Question: Which aircraft IDs are on the aircraft list, excluding ID 4, and are also on the airport aircraft list as 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: What are the Member IDs and their highest Branch IDs for members who satisfy at least one of these conditions: either their registration year is not 2016 and they are not from branch 1, or their registration year is not 2016, or their Member ID is 3 or greater, or they are from branch 8?

SELECT Member_ID, MAX(Branch_ID) FROM membership_register_branch WHERE Register_Year != "2016" AND Branch_ID <> "1" UNION SELECT Member_ID, MAX(Branch_ID) FROM membership_register_branch WHERE Register_Year <> "2016" OR "Member_ID" >= 3 OR Branch_ID = "8"


Question: Which Election IDs and First Elected years are common to elections that meet either of these conditions: the first elected year is not 1994, or the delegate is not DeBoy, or district is greater than 1 and party is not 2, or counties represented is not '09.1 9A' and election ID is at most 4, or the committee is 'Appropriations'; and also elections that meet either of these conditions: the first elected year is at most 2003 and the delegate is Turner, or district is at least 3, or counties represented is '13'?

SELECT Election_ID, First_Elected FROM election WHERE "First_Elected" <> 1994.0 OR Delegate != "DeBoy, Steven J. Sr. Steven J. DeBoy, Sr." OR "District" > 1 AND "Party" <> 2 OR Counties_Represented <> "09.1 9A" AND "Election_ID" <= 4 OR Committee = "Appropriations" INTERSECT SELECT Election_ID, First_Elected FROM election WHERE "First_Elected" <= 2003.0 AND Delegate = "Turner, Frank S. Frank S. Turner" OR "District" >= 3 OR Counties_Represented = "13"


Question: What are the Aircraft IDs, considering IDs of 5 or less from the aircraft table and IDs greater than 5 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 > 5


Question: What driver IDs, other than 3, are also 10 or more and appear in both the driver and school bus lists?

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 aircraft IDs are common between the aircraft and airport_aircraft tables, if we exclude ID 5 and only consider IDs up to 1?

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


Question: Are there any driver IDs that are 11 but not also school bus 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: Give me a list of Driver IDs that are specifically ID 3 from the driver table, and also include any Driver IDs that are 4 or less from the school bus table.

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


Question: What are the Driver IDs that are under 9 from the drivers and over 10 from the school buses?

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


Question: What are the minimum item ID from items with ID up to 6, and the minimum item ID from reviews that have either an item ID not equal to 7 and rank of 1 or more, or a user ID of 2, or a rating of 7 or less and an author ID less than 5?

SELECT MIN(i_id) FROM item WHERE "i_id" <= 6 UNION ALL SELECT MIN(i_id) FROM review WHERE "i_id" <> 7 AND "rank" >= 1 OR "u_id" = 2 OR "rating" <= 7 AND "a_id" < 5


Question: What are the driver IDs that are not 12 from the driver table, or are 3 or less 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 <= 3


Question: What information do you have about flights with these characteristics: either the company ID is not 5, or the flight number is not 'M2-F1 #6', or the date is not October 8, 1965, or the ID is not 10 and the pilot is not Thompson, or the velocity is 240 or more; or the airport ID is not 4, or the altitude is 3650 and the flight number is not 'M2-F1 #71', and the ID is less than 2, and the company ID is not 6, and the pilot is not Thompson, and the date is not 'May 19, 1964', or the velocity is less than 240?

SELECT airport_id, Date, id, Velocity, Vehicle_Flight_number, company_id, Altitude FROM flight WHERE "company_id" <> 5 OR Vehicle_Flight_number <> "M2-F1 #6" OR Date != "October 8, 1965" OR "id" != 10 AND Pilot <> "Thompson" OR "Velocity" >= 240.0 UNION SELECT airport_id, Date, id, Velocity, Vehicle_Flight_number, company_id, Altitude FROM flight WHERE "airport_id" <> 4 OR "Altitude" = 3650.0 AND Vehicle_Flight_number <> "M2-F1 #71" AND "id" < 2 AND "company_id" != 6 AND Pilot <> "Thompson" AND Date != "May 19, 1964" OR "Velocity" < 240.0


Question: Which school IDs belong to schools that are either not school ID '1' or are 'Knox Community' AAA with enrollment up to 379, but are not also associated with budget data where either the school ID is less than 4 and the budgeted percentage is below 1.3, or the invested percentage is above 2.2?

SELECT School_id FROM School WHERE School_name = "Knox Community" AND IHSAA_Class = "AAA" AND "Enrollment" <= 379 OR School_id <> "1" EXCEPT SELECT School_id FROM budget WHERE "School_id" < 4 AND "total_budget_percent_budgeted" < 1.3 OR "total_budget_percent_invested" > 2.2


Question: What are the names of aircraft that are not 'Airbus A320' and don't have an ID of 15, as well as the names of employees who earn more than 289950 and are not named 'Mark Young'?

SELECT name FROM aircraft WHERE name != "Airbus A320" AND "aid" != 15 UNION ALL SELECT name FROM employee WHERE "salary" > 289950 AND name != "Mark Young"


Question: What are the aircraft IDs that are 4 in the aircraft table or 5 in the airport aircraft table?

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


Question: What are the unique aircraft IDs from the aircraft table, other than 5, and from the airport_aircraft table, other than 3?

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


Question: What are the unique Aircraft IDs that are 3 or less from the aircraft list, combined with the unique Aircraft IDs that are not 3 from the airport aircraft list?

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


Question: Which driver IDs are drivers, but not driver ID 3, and also not driver ID 4 if driver ID 4 is a school bus driver?

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 is the average item ID for items that are not shampoo, and also the average item ID for reviews where either the reviewer ID is 5 or less, or the rating is less than 10 and the item ID is 1 or less?

SELECT AVG(i_id) FROM item WHERE title <> "shampoo" UNION SELECT AVG(i_id) FROM review WHERE "a_id" <= 5 OR "rating" < 10 AND "i_id" <= 1


Question: What are the driver IDs that are greater than 9, excluding any driver IDs that are 3 or less from the school bus records?

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: Which aircraft IDs, numbered 3 or lower, are listed in both the aircraft and airport aircraft tables?

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


Question: What are the highest item IDs in two separate cases: one for items that are not 'pear' or have an ID of 4, and another for items that are 'pear' or have an ID not equal to 0?

SELECT MAX(i_id) FROM item WHERE title != "pear" OR "i_id" = 4 UNION SELECT MAX(i_id) FROM item WHERE title = "pear" OR "i_id" <> 0


Question: What driver IDs are drivers with ID 1 or greater, but not school bus drivers with ID 9 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 <= 9


Question: What aircraft IDs, other than 5, are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 1 from 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 property features are there for properties with IDs less than 3, together with all property features that are not 'et'?

SELECT property_feature_description FROM Other_Property_Features WHERE "property_id" < 3 UNION ALL SELECT property_feature_description FROM Other_Property_Features WHERE property_feature_description <> "et"


Question: What are the average shipping agent codes for documents with ID up to 17 or 'u' in other details, and for shipping agents named 'UPS'?

SELECT AVG(shipping_agent_code) FROM Documents WHERE "document_id" <= 17 OR other_details = "u" UNION SELECT AVG(shipping_agent_code) FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS"


Question: Which driver ID, other than 1, is also driver ID 3 in the school bus table?

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


Question: Is driver ID 9 both a driver other than driver 2 and a school bus driver?

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


Question: Which driver IDs are in the driver list, but not 6, and are also not among the driver IDs less than 3 in the school bus list?

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


Question: Could you tell me the District ID, City Population, District Name, and Headquartered City for districts that are either district number 5, or not headquartered in Gujranwala City but have a population greater than 314617, or not headquartered in Gujrat City, or have a population of 165936 or less, or are not named Kasur District and have a city area that is not 75?

SELECT District_ID, City_Population, District_name, Headquartered_City FROM district WHERE "District_ID" = 5 OR Headquartered_City <> "Gujranwala City" AND "City_Population" > 314617.0 UNION SELECT District_ID, City_Population, District_name, Headquartered_City FROM district WHERE Headquartered_City <> "Gujrat City" OR "City_Population" <= 165936.0 OR "District_ID" >= 1 AND District_name <> "Kasur District" AND "City_Area" <> 75.0


Question: What are the city codes of students who are not 20 years old, or who are not from 'HOU', or whose last name is not 'Wilson' and student ID is less than 1011, or whose advisor is 2311 and first name is 'Bruce' and age is 20, or whose major is greater than 600?

SELECT city_code FROM Student WHERE "Age" != 20 UNION SELECT city_code FROM Student WHERE city_code <> "HOU" OR LName != "Wilson" AND "StuID" < 1011 OR "Advisor" = 2311 AND Fname = "Bruce" AND "Age" = 20 OR "Major" > 600


Question: What are the driver IDs that are 3 or less from the drivers and 7 or less from the school buses, without duplicates?

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


Question: What are the unique driver IDs that are either less than 10 from the driver list or less than or equal to 7 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 <= 7


Question: What are the Driver IDs, including those from drivers who are not number 4, and also those from school buses with IDs under 10?

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


Question: What driver IDs are common to drivers who are not driver 8 and school bus drivers with IDs of 3 or less?

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


Question: What driver IDs are 7 or less in the driver list, or is driver ID 7 in the school bus list?

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


Question: What are the Driver IDs of drivers who are not Democrats, or of school bus drivers who are not full-time, have not worked for 10 years, and have both Driver ID and School ID greater than 7?

SELECT Driver_ID FROM driver WHERE Party <> "Dem" UNION SELECT Driver_ID FROM school_bus WHERE If_full_time != "T" AND "Years_Working" != 10 AND "Driver_ID" > 7 AND "School_ID" > 7


Question: What is the average age and the year of award for employees who either received an award in 2015 and work in Sale, or are not named Jason Hobson?

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


Question: Which driver IDs are 2 or greater in the driver table, but are not in the school bus table, considering only school bus drivers who are not ID 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 driver IDs are both greater than 9 and not equal to 7, and are listed in both the driver and school bus records?

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


Question: What Driver IDs are both greater than 3 and up to 10, and are also school bus driver IDs?

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 party information do we have for entries where the governor is not Betsy McCaughey Ross, but only when the comptroller is Alan Hevesi and the party is either Independence or has a Party ID of 4 or less?

Democratic
Alan Hevesi
Eliot Spitzer
Carl McCall
(no election)
2002
3

Independence
Alan Hevesi
Jeanine Pirro
Eliot Spitzer
Hillary Rodham Clinton
2006
6

SELECT Party, Comptroller, Attorney_General, Governor, US_Senate, Year, Party_ID FROM party WHERE Governor <> "Betsy McCaughey Ross" EXCEPT SELECT Party, Comptroller, Attorney_General, Governor, US_Senate, Year, Party_ID FROM party WHERE Comptroller <> "Alan Hevesi" OR Party <> "Independence" AND "Party_ID" > 4


Question: What aircraft IDs are in the aircraft table, excluding ID 2, but not in the airport_aircraft table for IDs less than 1?

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


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

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


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


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

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


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

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


Question: What Aircraft IDs are 3 or greater in the aircraft table, or equal to 2 in the airport_aircraft table?

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


Question: What driver IDs are greater than 9, excluding driver ID 10 if it's a school bus driver?

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 department IDs for departments that are either temporary acting or are not temporary acting and have a head ID other than 4?

SELECT department_ID FROM management WHERE temporary_acting != "Yes" AND "head_ID" <> 4 UNION SELECT department_ID FROM management WHERE temporary_acting = "Yes"


Question: Which aircraft IDs are 2 or less, but not among the aircraft IDs greater than 1 in the airport aircraft records?

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 Pet IDs do we have for student 1002 and also for pets that are either 9.3 pounds and not cats, or have an ID of 2001?

SELECT PetID FROM Has_Pet WHERE "StuID" = 1002 UNION ALL SELECT PetID FROM Pets WHERE "weight" = 9.3 AND PetType != "cat" OR "PetID" = 2001


Question: What driver ID is both greater than 1 and also equal to 7?

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


Question: Which driver IDs, other than 1, are in the driver list but are not driver ID 7 in the school bus list?

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


Question: What driver IDs less than 10 are 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 < 10 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 10


Question: What branch IDs are in both the membership register for member 8 or any year other than 2016, and the purchase records for members 2 or less, purchases in 2018, or branch 5?

SELECT Branch_ID FROM membership_register_branch WHERE "Member_ID" = 8 OR Register_Year <> "2016" INTERSECT SELECT Branch_ID FROM purchase WHERE "Member_ID" <= 2 OR Year = "2018" OR Branch_ID = "5"


Question: What driver IDs are either less than 1 or 4 or greater, considering driver IDs from the driver list and the school bus list respectively?

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


Question: What are the Driver IDs, excluding ID 5 from the drivers and ID 10 from the school bus drivers?

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


Question: What are the IDs of drivers who are either younger than 30 or associated with school number 1?

SELECT Driver_ID FROM driver WHERE "Age" < 30 UNION SELECT Driver_ID FROM school_bus WHERE "School_ID" = 1


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

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


Question: What are the driver IDs, excluding 11, and also driver IDs less than 3 from the school bus system?

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 in both the driver and school bus lists and are at least 7?

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


Question: What is the highest bonus amount either for employees who are not employee ID 4 or if the bonus is 4000 or more, and also separately, what is the highest bonus amount for evaluations from years other than 2015 with bonuses less than 2900?

SELECT MAX(Bonus) FROM evaluation WHERE Employee_ID != "4" OR "Bonus" >= 4000.0 UNION ALL SELECT MAX(Bonus) FROM evaluation WHERE Year_awarded != "2015" AND "Bonus" < 2900.0


Question: Give me a list of album IDs for albums that are either numbered under 296 or are not called 'Unplugged', but remove any IDs that are also used for playlists not called 'Audiobooks'.

SELECT id FROM albums WHERE "id" < 296 OR title <> "Unplugged" EXCEPT SELECT id FROM playlists WHERE name <> "Audiobooks"


Question: What Aircraft IDs are either 4 or greater from the aircraft table, or 1 or less from the airport aircraft table?

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


Question: What are the continents and their IDs for continents with an ID of 5 or more, or if the continent is Africa?

SELECT Continent, ContId FROM continents WHERE "ContId" >= 5 UNION ALL SELECT Continent, ContId FROM continents WHERE Continent = "africa"


Question: Which aircraft IDs are greater than 4 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 > 4 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 2


Question: What driver IDs are not 2 from the drivers, or less than 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 driver IDs are both in the driver list and the school bus list, excluding driver ID 3 and only considering IDs less than 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 driver IDs are drivers but not school bus drivers, except for school bus driver 10?

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


Question: What are the Driver IDs, up to 9, that are in either the driver or school bus records?

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


Question: What Driver IDs are less than 1 in the driver list or less than 4 in 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 < 4


Question: What driver IDs are both in the driver list, excluding driver 11, and the school bus driver list, excluding driver 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


Question: What are the driver IDs that are greater than 6 in the driver list, or greater than or equal to 3 in the school bus list?

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


Question: What driver IDs are 10 or greater, but are not also driver IDs greater than 3 for school buses?

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


Question: What driver IDs are less than 11 from the drivers and less than 9 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 < 9


Question: What driver IDs are 9 or greater in the driver list, or 7 or greater in 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 agent IDs and ranks are found in reviews that satisfy both of these conditions: either the user ID is greater than 2 or the rank is 2 or less, and also the item ID is 1 and the agent ID is not 1?

SELECT a_id, rank FROM review WHERE "u_id" > 2 OR "rank" <= 2 INTERSECT SELECT a_id, rank FROM review WHERE "i_id" = 1 AND "a_id" <> 1


Question: Could you list the names of all branches named 'Taverner' that are not branch ID 1 and are not on Brampton Road, or have a membership amount of 6, together with the names of all members who are not member ID 2?

SELECT Name FROM branch WHERE Name = "Taverner" AND "Branch_ID" <> 1 AND Address_road <> "Brampton Road" OR membership_amount = "6" UNION SELECT Name FROM member WHERE "Member_ID" != 2


Question: What are the Country IDs that are either 15, or 6 or greater, or from countries that are not in continent 2 and are not named 'brazil'?

SELECT CountryId FROM countries WHERE "CountryId" = 15 UNION ALL SELECT CountryId FROM countries WHERE "Continent" <> 2 AND CountryName <> "brazil" OR "CountryId" >= 6


Question: What are the driver IDs, excluding 1, that are in the driver list but not in the list of school bus driver IDs greater than 3?

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


Question: What driver IDs are both less than 4 and also listed as school bus drivers, but not driver ID 7?

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


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

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


Question: Which driver ID is both not 10 and is 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 student IDs of club members who are not teaching coordinators and not in club 1, but are not among the students who meet certain other criteria?

SELECT StuID FROM Member_of_club WHERE Position <> "Teaching Coordinator" AND "ClubID" != 1 EXCEPT SELECT StuID FROM Student WHERE "Advisor" < 2311 AND "Age" >= 17 AND LName <> "Kim" OR Sex <> "F" OR city_code = "YYZ" OR Fname != "Mark" AND "StuID" >= 1025


Question: What are all the Driver IDs, including those under 10 from the driver list and those 10 or greater 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 are the driver IDs of drivers who are not driver 1, but are not also school bus drivers, excluding school bus driver 3?

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


Question: What are the unique Aircraft IDs that are either 1 or less 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 <= 1 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID != 1


Question: What are the driver IDs that are greater than 4 from the driver table, and also the driver IDs that are less than 7 from the school bus table?

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


Question: What driver IDs are 5 or less, except for driver ID 9 if it is listed for school buses?

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


Question: For each pet weight, can you list the Student IDs and that weight, but only if the weight is 13.4 or less, or the pet's age isn't 3, or the student ID is greater than 1002?

SELECT T1.StuID, T2.weight FROM Has_Pet as T1 JOIN Pets as T2 ON T1.PetID == T2.PetID GROUP BY weight HAVING weight <= 13.4 OR pet_age <> 3 OR StuID > 1002


Question: What Club IDs do we have for clubs that are either not in the USA or started in 2005, as well as for coaches with an ID of 2 or less?

SELECT Club_ID FROM club WHERE Region != "USA" OR "Start_year" = 2005 UNION ALL SELECT Club_ID FROM coach WHERE "Coach_ID" <= 2


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


Question: What Aircraft IDs are either not equal to 3 from the aircraft table or are 1 or greater 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 that are not 7 from the drivers and the Driver IDs that are 9 or greater from the school buses?

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


Question: What driver IDs are both greater than or equal to 7 and also listed as school bus drivers, 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: What customer IDs are associated with payments made at any time other than '2018-02-15 16:38:49', or with lessons that are not at 9 o'clock, not for customer 11, not on '2018-03-21 06:48:45', not cancelled, and either have a staff ID less than 8, a vehicle ID of 1, or a price of 295.0 or less?

SELECT customer_id FROM Customer_Payments WHERE datetime_payment <> "2018-02-15 16:38:49" UNION SELECT customer_id FROM Lessons WHERE lesson_time != "9" AND "customer_id" <> 11 AND lesson_date != "2018-03-21 06:48:45" AND lesson_status_code <> "Cancelled" AND "staff_id" < 8 OR "vehicle_id" = 1 OR "price" <= 295.0


Question: What are the city, zip code, state or county, address ID, country, and address line 1 for addresses that are both in the USA and not address ID 5?

Buckridgehaven
5
Oregon
4
USA
484 O'Hara Drive

Damianfort
61121
Connecticut
14
USA
4834 Schaefer Light Suite 947

Elviebury
63768
Connecticut
6
USA
376 Kallie Tunnel Apt. 784

Ericamouth
75074
Louisiana
13
USA
43235 Jazmin Mountain Suite 251

Hagenesfurt
22194
Kentucky
2
USA
053 Quigley Island

Lake Elaina
8938
Georgia
3
USA
00704 Zoe Alley

Lake Rafaela
80376
WestVirginia
8
USA
29085 Dejah Pine Suite 059

Lockmanfurt
34975
Washington
7
USA
56461 Baumbach Well Suite 634

New Bernieceburgh
38197
Louisiana
12
USA
7089 Mueller Forks

Port Jackelinemouth
85954
Maine
9
USA
535 Ariel Brook

Port Melyssa
14445
Georgia
1
USA
3904 Stroman Passage

South Eugene
99903
Alabama
11
USA
37698 Hahn Curve Apt. 572

South Richieport
95098
Idaho
10
USA
2291 Larkin Ports

West Edmondview
43988
Kentucky
15
USA
9260 Streich Mountain

SELECT city, zip_postcode, state_province_county, address_id, country, line_1_number_building FROM Addresses WHERE "address_id" <> 5 INTERSECT SELECT city, zip_postcode, state_province_county, address_id, country, line_1_number_building FROM Addresses WHERE country = "USA"


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

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


Question: Which driver IDs from the driver table are greater than 1, excluding driver ID 7 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 = 7


Question: Which driver IDs are 3 or more in the driver table but are not greater than 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: Which drivers, other than driver 5, are not also school bus drivers, other than driver 9?

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


Question: Which driver IDs are on both the list of drivers (excluding driver 11) and the list of school bus drivers (including only drivers with IDs of 3 or more)?

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 6 or greater, excluding driver ID 9 if it is associated with a school bus?

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


Question: Which driver IDs are for drivers with IDs greater than 1, but not for school bus drivers, excluding school bus driver ID 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 driver IDs are greater than 11 that are not also school bus driver IDs, ignoring school bus driver ID 3?

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


Question: What are all the aircraft IDs for aircraft with a distance over 1805, or not named 'Boeing 777-300', or not ID 9, or for certificates with an eid of 355548984 or less, or an ID less than 2?

SELECT aid FROM aircraft WHERE "distance" > 1805 OR name <> "Boeing 777-300" OR "aid" != 9 UNION ALL SELECT aid FROM certificate WHERE "eid" <= 355548984 OR "aid" < 2


Question: Which continents are neither Africa nor Europe and have a continent ID of 3 or more?

SELECT Continent FROM continents WHERE Continent <> "africa" INTERSECT SELECT Continent FROM continents WHERE Continent != "europe" AND "ContId" >= 3


Question: What are the document IDs for mailings sent to address ID 2, as well as for mailings not sent on April 1st, 1977 at 5:03 PM with a document ID under 20, or sent to address IDs of 0 or less?

SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" = 2 UNION ALL SELECT document_id FROM Documents_Mailed WHERE mailing_date <> "1977-04-01 17:03:50" AND "document_id" < 20 OR "mailed_to_address_id" <= 0


Question: Which driver IDs are number 5 in the driver table, but not greater than 7 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 > 7


Question: What are the names of all employees who either have an ID of 287321212 or greater and a salary other than 44740, or are not named Lisa Walker?

SELECT name FROM employee WHERE "eid" >= 287321212 AND "salary" != 44740 UNION ALL SELECT name FROM employee WHERE name <> "Lisa Walker"


Question: What document type codes have the description 'u'?

SELECT document_type_code FROM Ref_Document_Types WHERE document_type_code = "Hard Drive" OR document_type_description = "u" EXCEPT SELECT document_type_code FROM Ref_Document_Types WHERE document_type_code = "Hard Drive"


Question: What are the names of airports that are named "El Prat Airport" and have an ICAO code of "BIAR", or have an IATA code that is not "BOS", or have an ID of 2, or have an ID of 1 and are not named "Logan International Airport" and are in Bergen, or are in the United States and have an IATA code that is not "ANC"?

SELECT name FROM airport WHERE name = "El Prat Airport" AND ICAO = "BIAR" OR IATA <> "BOS" OR "id" = 2 UNION SELECT name FROM airport WHERE "id" = 1 AND name != "Logan International Airport" AND City = "Bergen" OR Country = "United States" AND IATA != "ANC"


Question: Is driver ID 7 in both the driver list (excluding driver 8) and the school bus list?

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 Aircraft IDs are in both the aircraft and airport aircraft lists and are greater than 1?

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: Which Aircraft IDs are both 5 or greater and listed in the aircraft table, and also not equal to 3 and listed in the airport aircraft table?

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


Question: What are the driver IDs that are drivers but not school bus drivers, excluding driver ID 7 and considering only school bus drivers with IDs up to 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 driver IDs are 1 or less from the driver table, or driver ID 4 from the school bus table?

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


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


Question: What driver IDs are greater than 9 in the drivers table, but not also driver IDs less than or equal to 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 aircraft IDs are 5 or less in the aircraft table, but not among those less than 3 in the airport aircraft table?

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


Question: What Aircraft IDs are greater than 4 and are also listed in the 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 >= 3


Question: For albums, what's the average ID of those that are either not named 'Arquivo Os Paralamas Do Sucesso', or are not by artist 234 and not album ID 29? And for media types, what's the average ID of those not named 'Purchased AAC audio file'?

SELECT AVG(id) FROM albums WHERE title <> "Arquivo Os Paralamas Do Sucesso" OR "artist_id" <> 234 AND "id" != 29 UNION ALL SELECT AVG(id) FROM media_types WHERE name != "Purchased AAC audio file"


Question: What are the distances, and for each distance, what is the maximum aircraft ID and the count of aircraft names, where either: (1) if we exclude aircraft ID 11, then for that distance, the count of aircraft names is 1 or the maximum aircraft ID is 8 or less, OR (2) if we exclude 'Airbus A319' and consider distances greater than 1530, then for that distance, the count of aircraft names is not 1?

SELECT MAX(aid), COUNT(name), distance FROM aircraft WHERE "aid" != 11 GROUP BY distance HAVING COUNT(name) = 1 OR MAX(aid) <= 8 UNION SELECT MAX(aid), COUNT(name), distance FROM aircraft WHERE name != "Airbus A319" AND "distance" > 1530 GROUP BY distance HAVING COUNT(name) <> 1


Question: What are the car makers who are either not from country '4', or are 'Honda' made by Daimler Benz, in the car makers list, or are not maker ID 18, not 'pontiac' models, and have a model ID greater than 23 in the model list? Give me a list of unique maker names.

SELECT Maker FROM car_makers WHERE Country != "4" OR FullName = "Honda" AND Maker = "daimler benz" UNION SELECT Maker FROM model_list WHERE "Maker" != 18 AND Model != "pontiac" AND "ModelId" > 23


Question: Which Driver IDs are 5 or less from the driver list, or not 10 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 != 10


Question: What is the total number of customers if we combine two groups: those who either paid $5475.26 or less, or are customer ID 10, and those who meet specific criteria about their contact information and personal details?

SELECT COUNT(customer_id) FROM Customer_Payments WHERE "amount_payment" <= 5475.26 OR "customer_id" = 10 UNION ALL SELECT COUNT(customer_id) FROM Customers WHERE email_address <> "nichole59@example.com" AND cell_mobile_phone_number = "577-584-4864" AND date_became_customer <> "2015-09-25 13:59:21" AND "customer_id" = 5 OR first_name != "Estelle" OR date_of_birth != "1991-02-10 00:42:17"


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

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


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

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


Question: What are the minimum start date, average shop ID, and sum of employee IDs for employees who meet either of these conditions: their shop ID is greater than 1, or they are full-time, have an employee ID greater than 3, and their start date is not 2011? Also, calculate the same for employees with employee ID 5 and shop ID greater than or equal to 1. Combine the results.

SELECT MIN(Start_from), AVG(Shop_ID), SUM(Employee_ID) FROM hiring WHERE "Shop_ID" > 1 OR Is_full_time <> "F" AND "Employee_ID" > 3 AND Start_from <> "2011" UNION SELECT MIN(Start_from), AVG(Shop_ID), SUM(Employee_ID) FROM hiring WHERE "Employee_ID" = 5 AND "Shop_ID" >= 1


Question: What driver IDs are either exactly 9 from the drivers or less than or equal to 3 from the school buses?

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


Question: What are the IDs of drivers who are not driver 10 and are not school bus drivers with IDs up to 9?

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


Question: What are the IDs of albums not from artist 100, and the IDs of media types other than ID 2?

SELECT id FROM albums WHERE "artist_id" != 100 UNION SELECT id FROM media_types WHERE "id" != 2


Question: Show me the Driver IDs that are 10 or greater from the driver list, and also include Driver ID 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 Aircraft IDs are 5 or less, but not Aircraft ID 2 from 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 are the maximum School ID, maximum IHSAA Football Class, IHSAA Class, Enrollment, Mascot, average School Name, and maximum County for schools that meet certain conditions related to their school information?

SELECT MAX(School_id), MAX(IHSAA_Football_Class), IHSAA_Class, Enrollment, Mascot, AVG(School_name), MAX(County) FROM School WHERE School_id = "7" AND IHSAA_Football_Class <> "AA" OR County = "46 LaPorte 71 St. Joseph" OR Location != "Bremen" OR IHSAA_Class != "AA" AND Mascot <> "Cavaliers" OR School_name <> "Triton" UNION SELECT MAX(School_id), MAX(IHSAA_Football_Class), IHSAA_Class, Enrollment, Mascot, AVG(School_name), MAX(County) FROM School WHERE Mascot = "Trojans" AND School_name = "Culver Community" OR County <> "46 LaPorte 71 St. Joseph" AND School_id = "1" AND Location = "Lakeville"


Question: What driver IDs are both not equal to 8 and less than 10, and are present in both driver and 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 < 10


Question: What aircraft IDs, other than 4, are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 1 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 <> 1


Question: What driver IDs are greater than 2 from the drivers, or not equal to 9 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 != 9


Question: What feature IDs do we have for available features that are not 'BurglarAlarm' and have an ID of 3, or for property features described as 'doloribus'?

SELECT feature_id FROM Other_Available_Features WHERE feature_name <> "BurglarAlarm" AND "feature_id" = 3 UNION SELECT feature_id FROM Other_Property_Features WHERE property_feature_description = "doloribus"


Question: What aircraft IDs, other than 2, are in the aircraft table but not among aircraft IDs that are 1 or less 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 is the count of mailed documents with document IDs greater than 2, but only if that count is different from the count of draft copies with document IDs less than 1?

SELECT COUNT(document_id) FROM Documents_Mailed WHERE "document_id" > 2 EXCEPT SELECT COUNT(document_id) FROM Draft_Copies WHERE "document_id" < 1


Question: What are the driver IDs that are 12 in the driver table and not 7 in the school bus table?

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


Question: What are the document IDs, the number of drafts, and the sum of draft details for documents where the draft number is greater than 12 and draft details is not 'v', or the document ID is greater than 20, or the draft details is not 'k'?

SELECT document_id, COUNT(draft_number), SUM(draft_details) FROM Document_Drafts WHERE "draft_number" > 12 AND draft_details <> "v" OR "document_id" > 20 UNION SELECT document_id, COUNT(draft_number), SUM(draft_details) FROM Document_Drafts WHERE draft_details != "k"


Question: What are the counts of ranks? One count from match results where either 'Small Silver' is 10 and 'Points' is greater than 168, or 'Club ID' is 5 or less. And another count from players who are either (not ranked '3rd', female, 'Locomotive Engineer', with at least 8734 votes, and not player ID 7) or named something other than 'Fiona Shiells'.

SELECT COUNT(Rank) FROM match_result WHERE "Small_Silver" = 10 AND "Points" > 168 OR "Club_ID" <= 5 UNION SELECT COUNT(Rank) FROM player WHERE Rank <> "3rd" AND Gender = "F" AND Occupation = "Locomotive Engineer" AND "Votes" >= 8734 AND "Player_ID" != 7 OR Player_name <> "Fiona Shiells"


Question: Which Aircraft IDs, other than 4, are listed in the aircraft table but not 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 != 5


Question: What are the driver IDs that are greater than 9, combined with the driver IDs that are less than 9?

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


Question: What are the Player IDs for players who are not male, are not player ID 12, and are not 'Self Employed / Consultant', unless their sponsor is not 'Provencher', or they have more than 14097 votes, or their rank is not '4th', or they live in 'Selkirk', or their name is not 'Ross Eadie', and who are also associated with a coach with an ID greater than 2, or have a starting year of 2010 or earlier if their Player ID is 1?

SELECT Player_ID FROM player WHERE "Player_ID" != 12 AND Gender != "M" AND Occupation <> "Self Employed / Consultant" OR Sponsor_name != "Provencher" OR "Votes" > 14097 OR Rank <> "4th" OR Residence = "Selkirk" OR Player_name != "Ross Eadie" INTERSECT SELECT Player_ID FROM player_coach WHERE "Coach_ID" > 2 OR "Starting_year" <= 2010 AND "Player_ID" = 1


Question: What are the aircraft IDs, excluding 3, from the aircraft table, together with aircraft IDs less than 2 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 < 2


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


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

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


Question: Which driver IDs are 9 or greater and are drivers, but are not school bus drivers with IDs less than 9?

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


Question: Is the average maker value for car makers, not including ID 4 and 'subaru', different from the average maker value for models where maker is less than 6? If so, what is the average for those car makers?

SELECT AVG(Maker) FROM car_makers WHERE "Id" <> 4 AND Maker != "subaru" EXCEPT SELECT AVG(Maker) FROM model_list WHERE "Maker" < 6


Question: What driver IDs are either exactly 2 from the driver list or less than 9 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 < 9


Question: What item IDs, other than 1, are in the item list but not in the list of reviewed items if the review was made by an author with ID 5 or less for item 7, or by a user with ID greater than 2?

SELECT i_id FROM item WHERE "i_id" <> 1 EXCEPT SELECT i_id FROM review WHERE "a_id" <= 5 AND "i_id" = 7 OR "u_id" > 2


Question: What are the driver IDs, other than 4, of drivers who are not also 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 != 4


Question: What driver IDs are both not equal to 11 from the drivers and not equal to 10 from the school bus drivers?

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


Question: Show me the car maker IDs and their counts of countries, makers, and full names that meet the first set of conditions but not the second set.

COUNT(Country) COUNT(Maker) Id COUNT(FullName)

SELECT COUNT(Country), COUNT(Maker), Id, COUNT(FullName) FROM car_makers WHERE Maker <> "honda" OR "Id" = 7 OR FullName <> "Triumph" OR Country <> "1" GROUP BY Id HAVING COUNT(Country) <= 1 EXCEPT SELECT COUNT(Country), COUNT(Maker), Id, COUNT(FullName) FROM car_makers WHERE Country <> "2" OR FullName <> "Ford Motor Company" AND Maker != "hyundai" AND "Id" > 14 GROUP BY Id HAVING COUNT(FullName) = 1 AND COUNT(Maker) <> 1


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

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


Question: What driver IDs are either driver number 2, or any driver number other than 3 from the 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 <> 3


Question: List the address, membership amount, branch ID, open year, name, and city for branches that were not opened in 2013, and also list the same information for branches that are either not named 'Cochrane', or not opened in 2015, or have a Branch ID of 4 and are not on 'Valleys Place', or have a membership amount other than 1418 and are located in 'Oxford'.

SELECT Address_road, membership_amount, Branch_ID, Open_year, Name, City FROM branch WHERE Open_year != "2013" UNION ALL SELECT Address_road, membership_amount, Branch_ID, Open_year, Name, City FROM branch WHERE Name <> "Cochrane" OR Open_year != "2015" OR "Branch_ID" = 4 AND Address_road != "Valleys Place" OR membership_amount <> "1418" AND City = "Oxford"


Question: What are the sums of customer IDs for two groups: first, customers who became customers on '2017-11-25 01:42:26', are 'Good Customers', and have a phone number other than '417.136.2900x672', or a last name other than 'Goodwin'; and second, lessons that are 'Cancelled', have a vehicle ID not equal to 1, and a staff ID greater than 12?

SELECT SUM(customer_id) FROM Customers WHERE date_became_customer = "2017-11-25 01:42:26" AND phone_number != "417.136.2900x672" AND customer_status_code = "Good Customer" OR last_name != "Goodwin" UNION SELECT SUM(customer_id) FROM Lessons WHERE lesson_status_code = "Cancelled" AND "vehicle_id" <> 1 AND "staff_id" > 12


Question: What Driver IDs are either 8 or greater from the driver list, or less than 9 from 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 < 9


Question: What aircraft IDs are both greater than 2 in the aircraft table and equal to 3 in the airport aircraft table?

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


Question: What are the Aircraft IDs, specifically those not equal to 5 from the aircraft table, and those less than 5 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 < 5


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

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


Question: Which driver IDs are 5 or greater, but are not among the school bus driver IDs that are greater than 7?

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


Question: Could you list driver ID 2 and all driver IDs less than 4 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 < 4


Question: What aircraft IDs are not 1 in the aircraft table, and also include 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 < 2


Question: What are the Aircraft IDs? Show me Aircraft ID 3 from the aircraft table and all other Aircraft IDs from the airport_aircraft table.

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


Question: What are the county names, county IDs, and zip codes for counties that either have a county ID greater than 3, or are not named 'Howard' and don't have a zip code of 'D21', or are not named 'Mansfield', or have a county ID of 5 and a population of 90000 or less?

SELECT County_name, County_Id, Zip_code FROM county WHERE "County_Id" > 3 OR Zip_code <> "D21" AND County_name != "Howard" UNION SELECT County_name, County_Id, Zip_code FROM county WHERE County_name <> "Mansfield" OR "County_Id" = 5 AND "Population" <= 90000.0


Question: What are the driver IDs that are greater than 11 and are drivers, but not school bus drivers with IDs of 10 or greater?

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


Question: What address ID and address details are associated with address ID 3, and also have address details that are not 'IT'?

SELECT address_id, address_details FROM Addresses WHERE "address_id" = 3 INTERSECT SELECT address_id, address_details FROM Addresses WHERE address_details != "IT" AND "address_id" <> 5


Question: List the aircraft IDs that are number 1 from the aircraft table, or any number except 3 from the airport aircraft table.

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


Question: What aircraft IDs are in the aircraft table, except for 2, or in the airport_aircraft table, except for 1?

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 driver IDs are for drivers, excluding driver 8, that are not also school bus drivers with IDs greater than 7?

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


Question: What is the alphabetically last state in the AREA_CODE_STATE table, excluding New Jersey, that is not also the alphabetically last state in the VOTES table when we only consider votes where the contestant number is not 3, or the vote was not created on '2018-03-09 19:03:21' in California, or the vote ID is not 1?

SELECT MAX(state) FROM AREA_CODE_STATE WHERE state <> "NJ" EXCEPT SELECT MAX(state) FROM VOTES WHERE "contestant_number" != 3 OR created != "2018-03-09 19:03:21" AND state = "CA" OR "vote_id" != 1


Question: What driver IDs are 8 or greater in the driver table but not in the school bus table if they are 3 or greater?

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


Question: What is the smallest document ID for documents in the Documents table if they have a receipt date of '1976-09-15 19:24:17', or are not document ID 20, or have 'UP' as the shipping agent code, or have other details not equal to 'u'? Also, what is the smallest document ID in the Draft_Copies table for drafts that are not draft number 20?

SELECT MIN(document_id) FROM Documents WHERE receipt_date = "1976-09-15 19:24:17" OR "document_id" <> 20 OR shipping_agent_code = "UP" OR other_details != "u" UNION ALL SELECT MIN(document_id) FROM Draft_Copies WHERE "draft_number" <> 20


Question: What driver IDs are there that are at least 8 in the driver table, or greater than 3 in the school bus table?

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


Question: What driver IDs are there, other than 6, and also including 9 from the 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 = 9


Question: What driver IDs are both for drivers with IDs up to 4 and for school bus drivers with IDs greater than 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, 7 or less, are drivers but not school bus drivers, excluding school bus driver 10?

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


Question: What driver IDs are for drivers who are not driver 2 and are also for school bus drivers with IDs less than 4?

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


Question: What are the driver IDs that are less than 8 or are not 3 from 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 != 3


Question: What are the driver IDs that are exactly 4 in the driver records, or 3 or greater in the school bus records?

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


Question: What are the driver IDs that are greater than 2 in the driver list or less than 7 in 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 < 7


Question: Give me the driver IDs, excluding 10, that are not also driver ID 4 in the school bus records.

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: Could you list all the Club IDs that are either from clubs not started in 2000, not in the USA, and not named 'Gefle IF', or with ID 2, as well as from match results where the Club ID is less than 3, or Small Silver is 10 or less and Points is not 66, or Big Silver is less than 9, or Gold is 7?

SELECT Club_ID FROM club WHERE "Start_year" != 2000 AND Region <> "USA" AND Club_name != "Gefle IF" OR "Club_ID" = 2 UNION ALL SELECT Club_ID FROM match_result WHERE "Club_ID" < 3 OR "Small_Silver" <= 10 AND "Points" != 66 OR "Big_Silver" < 9 OR "Gold" = 7


Question: Is driver ID 9 present in both the driver and school bus tables?

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


Question: Could you find the minimum airport ID and the pilot for records that are associated with either airport BLL, Bergen Airport, airports in Belgium, or airports in Akureyri, or flights with an altitude other than 3650, an airport ID other than 1, a company ID of 11 or higher, a velocity other than 240, a date of October 25, 1963, or a pilot other than Thompson?

SELECT MIN(T1.id), T2.Pilot FROM airport as T1 JOIN flight as T2 ON T1.id = T2.id WHERE IATA = "BLL" AND "Altitude" <> 3650.0 AND "airport_id" <> 1 OR name = "Bergen Airport" OR "company_id" >= 11 AND Country = "Belgium" AND "Velocity" <> 240.0 AND Date = "October 25, 1963" OR City = "Akureyri" OR Pilot <> "Thompson"


Question: Could you list the nationality, name, height, people ID, and birth date for all individuals who are either not person number 2, or are not Russian and 182cm or shorter, or whose name is not Roman Bragin?

SELECT Nationality, Name, Height, People_ID, Birth_Date FROM people WHERE "People_ID" <> 2 OR Nationality != "Russia" AND "Height" <= 182.0 UNION ALL SELECT Nationality, Name, Height, People_ID, Birth_Date FROM people WHERE Name <> "Roman Bragin"


Question: What are the branch IDs from membership records not in 2017, or not branch 2, or with member ID up to 3, and also from purchase records with member ID not 1?

SELECT Branch_ID FROM membership_register_branch WHERE Register_Year <> "2017" OR Branch_ID <> "2" OR "Member_ID" <= 3 UNION SELECT Branch_ID FROM purchase WHERE "Member_ID" != 1


Question: What Aircraft IDs are both less than 4 in the aircraft table and at least 3 in the airport aircraft table?

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


Question: What aircraft IDs are 2 or less from the aircraft table, or exactly 3 from the airport_aircraft table?

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


Question: What are the unique Aircraft IDs that are not equal to 1 from the aircraft table, or are less than 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 address details are 'DE' from the addresses with IDs up to 4?

SELECT address_details FROM Addresses WHERE "address_id" <= 4 EXCEPT SELECT address_details FROM Addresses WHERE "address_id" >= 1 AND address_details != "DE"


Question: Which driver IDs are in the driver table (not 5) and also in the school bus table (specifically 9)?

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


Question: What driver IDs are in both the driver list and the school bus list, and are less than 7?

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


Question: What driver IDs are both less than 9 and also less than or equal to 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: Which driver IDs are on both the list of drivers, excluding driver 7, and the list of school bus drivers, only including IDs 1, 2, and 3?

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


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


Question: What are the arrival dates for flights that either departed at 6:30 AM on December 4th, 2005, or have flight ID 6, and also the arrival dates for flights with flight numbers up to 99 that cost 425.98 or more and didn't depart at 8:45 AM on December 4th, 2005?

SELECT arrival_date FROM flight WHERE departure_date = "04/12/2005 06:30" OR "aid" = 6 UNION ALL SELECT arrival_date FROM flight WHERE "flno" <= 99 AND "price" >= 425.98 AND departure_date != "04/12/2005 08:45"


Question: What driver IDs are 10 or less in the driver table, but not among the driver IDs greater than 3 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 > 3


Question: What driver IDs are less than 8 in the driver table, or are exactly 7 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 = 7


Question: What are the aircraft IDs that are 4 in the aircraft table, and also those that are not 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 listed in both the driver table, excluding driver 10, and the school bus table, excluding driver 4?

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


Question: What driver IDs are either greater than 12 from the driver list or not equal to 3 from the school bus list?

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


Question: What Aircraft IDs are listed in both the aircraft table, excluding ID 5, and the airport aircraft table, specifically those IDs less than 2?

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


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

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


Question: What are the driver IDs that are greater than 8, along with driver ID 3?

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