Question: Which driver IDs are equal to 10 in the driver table but not less than 4 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 < 4


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

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


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

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


Question: What are the aircraft IDs that are either greater than or equal to 1 in the aircraft table, or not equal to 5 in the airport_aircraft table?

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


Question: What are the names of clubs that satisfy both of these conditions: either their ID is greater than 4 and their name isn't Helsingborgs IF, or their region isn't UK, or their start year is before 2000; and either their start year is 2009, or their region isn't Korea, or their name isn't Halmstads BK?

SELECT Club_name FROM club WHERE "Club_ID" > 4 AND Club_name <> "Helsingborgs IF" OR Region <> "UK" OR "Start_year" < 2000 INTERSECT SELECT Club_name FROM club WHERE "Start_year" = 2009 OR Region != "Korea" OR Club_name != "Halmstads BK"


Question: What parties participated in elections where the delegate wasn't James E. Malone Jr. or the number of represented counties wasn't 13 and the district was at least 2 or the first election was in or after 2002 and the committee wasn't Appropriations and the party value was less than 7 and the election ID was no more than 4, and also what parties had a lieutenant governor other than David Paterson and a comptroller named Alan Hevesi?

SELECT Party FROM election WHERE Delegate != "Malone, James E. Jr. James E. Malone, Jr." OR Counties_Represented != "13" AND "District" >= 2 OR "First_Elected" >= 2002.0 AND Committee <> "Appropriations" AND "Party" < 7 AND "Election_ID" <= 4 UNION ALL SELECT Party FROM party WHERE Lieutenant_Governor != "David Paterson" AND Comptroller = "Alan Hevesi"


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

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


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

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


Question: Which driver IDs are less than 3, excluding driver ID 7?

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


Question: What are the other details from documents that are not overdue, not shipped by UP, not "z", not received on December 25, 2014 at 17:22:44, and don't have a receipt number of "8", or are of type "Paper", or have a document ID greater than 17, excluding any other details found in the employee records where the employee name is not Koby?

SELECT other_details FROM Documents WHERE document_status_code <> "overdue" AND shipping_agent_code <> "UP" AND other_details <> "z" AND receipt_date != "2014-12-25 17:22:44" AND receipt_number <> "8" OR document_type_code = "Paper" OR "document_id" > 17 EXCEPT SELECT other_details FROM Employees WHERE employee_name <> "Koby"


Question: What is the sum of the 'state' values from the 'AREA_CODE_STATE' table where the state is "NM" or the area code is not 720, combined with the sum of 'state' values from the 'VOTES' table where the state is "NY" or the created date is not "2018-03-09 19:03:36" and the phone number is greater than or equal to 7182887233 or the contestant number is greater than 2 and the vote ID is greater than or equal to 3?

SELECT SUM(state) FROM AREA_CODE_STATE WHERE state = "NM" OR "area_code" <> 720 UNION ALL SELECT SUM(state) FROM VOTES WHERE state = "NY" OR created != "2018-03-09 19:03:36" AND "phone_number" >= 7182887233 OR "contestant_number" > 2 AND "vote_id" >= 3


Question: What are the template ID, document ID, description, name, and other details for documents where the template ID is greater than 14 and the description is not "y", or the other details are "None", or the name is not "Data base"? Also, what are the template ID, document ID, description, name, and other details for documents where the other details are "None", or the name is "Data base" and the template ID is at least 6, or the document ID is at least 80 and the description is not "f"?

SELECT Template_ID, Document_ID, Document_Description, Document_Name, Other_Details FROM Documents WHERE "Template_ID" > 14 AND Document_Description <> "y" OR Other_Details = "None" OR Document_Name != "Data base" UNION SELECT Template_ID, Document_ID, Document_Description, Document_Name, Other_Details FROM Documents WHERE Other_Details = "None" OR Document_Name = "Data base" AND "Template_ID" >= 6 OR "Document_ID" >= 80 AND Document_Description != "f"


Question: What are the driver IDs less than 9 that are in the driver table but not in the school bus table, excluding those with a driver ID of 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 less than 4 but not equal to 10, considering only driver IDs from the driver table and 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 = 10


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

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


Question: What are the states associated with area codes greater than 210, combined with the states where the contestant number is not 3?

SELECT state FROM AREA_CODE_STATE WHERE "area_code" > 210 UNION SELECT state FROM VOTES WHERE "contestant_number" <> 3


Question: What are the aircraft IDs that are not 4 and are in the aircraft table, but not in the airport_aircraft table with an ID of 1?

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


Question: What is the sum of document IDs for records where the draft number is not 17 and the employee ID is 2, or where the document ID is not 1, excluding the sum of document IDs for records where the document ID is 20 or greater, the copy number is 5 or less, and the draft number is not 17?

SELECT SUM(document_id) FROM Circulation_History WHERE "draft_number" != 17 AND "employee_id" = 2 OR "document_id" <> 1 EXCEPT SELECT SUM(document_id) FROM Circulation_History WHERE "document_id" >= 20 AND "copy_number" <= 5 AND "draft_number" <> 17


Question: What are the IDs of drivers who are in both the driver table (excluding driver ID 10) and the school bus table (with driver IDs greater than 7)?

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


Question: Which driver IDs are either 1 or 10 or greater?

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 are the driver IDs that are less than or equal to 5, excluding driver ID 4, considering only driver IDs from the driver and school bus tables?

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


Question: What are the aircraft IDs, excluding ID 1, that appear in both the aircraft and airport_aircraft tables?

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


Question: What is the maximum aircraft ID and the corresponding airport ID, based on the aircraft and airport aircraft information?

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


Question: What are the driver IDs greater than 1, and also any driver IDs from school buses that are not 7?

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


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

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


Question: Which driver IDs are either 4 or greater than 3?

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


Question: What are the driver IDs that are less than 11, and also the driver IDs that are greater than 9?

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


Question: What are the driver IDs that are less than 3, and also the driver ID that is 3, considering both drivers and school buses?

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: How many stores are not "City Mall" or have a store ID less than or equal to 1 and less than 1170 product categories, combined with the number of stores in districts that are not district ID 4 and not store ID 1?

SELECT COUNT(Store_ID) FROM store WHERE Type <> "City Mall" OR "Store_ID" <= 1 AND "Number_of_product_category" < 1170.0 UNION ALL SELECT COUNT(Store_ID) FROM store_district WHERE "District_ID" <> 4 AND "Store_ID" <> 1


Question: What are the aircraft IDs that are less than 1 in the aircraft table, combined with the aircraft IDs less than 3 in the airport_aircraft table?

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


Question: Which aircraft IDs are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 5 from both?

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


Question: Which driver IDs are not equal to 9, but are not also driver IDs from school buses with IDs greater than 10?

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


Question: What are the names of users with a user ID of 3 or less, or with a user ID of 2 and a name that isn't Helen?

SELECT name FROM useracct WHERE "u_id" <= 3 UNION SELECT name FROM useracct WHERE name != "Helen" AND "u_id" = 2


Question: What are the driver IDs that are less than or equal to 9, excluding driver ID 7?

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


Question: What are the album IDs greater than 98, or not by artist 51, or not titled "The Office, Season 2", along with playlist IDs less than 11?

SELECT id FROM albums WHERE "id" > 98 OR "artist_id" <> 51 OR title <> "The Office, Season 2" UNION ALL SELECT id FROM playlists WHERE "id" < 11


Question: What are the branch IDs that are either branch 5 in any year except 2016, or any branch ID other than 1?

SELECT Branch_ID FROM membership_register_branch WHERE Register_Year != "2016" AND Branch_ID = "5" UNION SELECT Branch_ID FROM membership_register_branch WHERE Branch_ID != "1"


Question: What are the IDs of drivers who are not driver ID 3 and are also driver IDs greater than 4, considering only drivers and school buses?

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


Question: Which driver IDs are greater than 7 but not equal to 3 in the school bus records?

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


Question: What are the names and IDs of airports that are not in BGO or that don't have the ICAO code EKBI, combined with the names and IDs of operating companies with IDs less than 6 and that are not subsidiaries?

SELECT name, id FROM airport WHERE IATA <> "BGO" OR ICAO != "EKBI" UNION ALL SELECT name, id FROM operate_company WHERE "id" < 6 AND Type != "Subsidiary"


Question: Which driver IDs are less than 4 but not equal to 4, considering only driver IDs from the driver table and excluding those from 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 <> 4


Question: What are the different positions in the club, along with the number of club IDs and the sum of student IDs, considering either club IDs not equal to 1 or student IDs greater than 1010 and positions not equal to "CTO", or club ID is 4 or student ID is not 1007?

SELECT Position, COUNT(ClubID), SUM(StuID) FROM Member_of_club WHERE "ClubID" <> 1 OR "StuID" > 1010 AND Position <> "CTO" UNION SELECT Position, COUNT(ClubID), SUM(StuID) FROM Member_of_club WHERE "ClubID" = 4 OR "StuID" <> 1007


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

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


Question: Which driver IDs are either 8 or 9 and above?

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


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

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


Question: What are the driver IDs that are both less than or equal to 11 and also not equal to 9, considering driver IDs from the driver and school bus tables?

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


Question: Which driver IDs are less than 6, excluding driver ID 3, considering only driver IDs from the driver and school bus tables?

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


Question: What are the driver IDs greater than or equal to 2, excluding driver ID 7?

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


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

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


Question: What are the book IDs that satisfy either of these conditions: the writer is not Christopher Hinz, the title is not Bloody Mary, the issue number is not 4.0, or the book ID is 9, and also satisfy any of these conditions: the book ID is greater than or equal to 7, the price is less than or equal to 3,000,000 and the publication ID is less than 1 and the publication date is June 2006, or the publisher is Pearson?

SELECT Book_ID FROM book WHERE Writer != "Christopher Hinz" OR Title != "Bloody Mary" OR "Issues" <> 4.0 OR "Book_ID" = 9 INTERSECT SELECT Book_ID FROM publication WHERE "Book_ID" >= 7 OR "Price" <= 3000000.0 AND "Publication_ID" < 1 AND Publication_Date = "June 2006" OR Publisher = "Pearson"


Question: What are the aircraft IDs that are greater than or equal to 4 and also present in the airport aircraft table with IDs greater than 3?

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


Question: Which driver IDs are less than or equal to 5, but not equal to 9, considering only the driver IDs present in the driver table and excluding those in the school bus table?

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


Question: What are the driver IDs greater than 7, and also the driver IDs less than 3, considering both drivers and 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 < 3


Question: What are the driver IDs, where one ID is 2 from the driver table and another ID is 9 from the school bus table?

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


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

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


Question: What are the company and people IDs for those who have worked for more than one year, and also for those who have worked for more than one year, or have a people ID less than or equal to 4, or a company ID less than or equal to 11?

SELECT Company_ID, People_ID FROM employment WHERE "Year_working" > 1 INTERSECT SELECT Company_ID, People_ID FROM employment WHERE "Year_working" > 1 OR "People_ID" <= 4 OR "Company_ID" <= 11


Question: What are the driver IDs, excluding driver ID 6, and also the driver IDs less than 7?

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


Question: For each IHSAA class, how many locations and school names are there, but only show results where the number of locations is at least 2 or the number of school names is greater than 2, or where the number of locations is less than 4 and the number of school names is not equal to 2?

SELECT IHSAA_Class, COUNT(Location), COUNT(School_name) FROM School GROUP BY IHSAA_Class HAVING COUNT(Location) >= 2 OR COUNT(School_name) > 2 UNION SELECT IHSAA_Class, COUNT(Location), COUNT(School_name) FROM School GROUP BY IHSAA_Class HAVING COUNT(Location) < 4 AND COUNT(School_name) <> 2


Question: What are the shipping agent code, document status code, other details, document type code, document ID, receipt date, and receipt number for documents that satisfy either of these conditions: the document status is not "overdue" and the receipt number is not "8", or the document ID is greater than 14, or the receipt date is "1986-12-14 14:18:59"; and also satisfy either of these conditions: the other details are "u", or the receipt date is not "1974-05-08 00:00:46"?

SELECT shipping_agent_code, document_status_code, other_details, document_type_code, document_id, receipt_date, receipt_number FROM Documents WHERE document_status_code != "overdue" AND receipt_number != "8" OR "document_id" > 14 OR receipt_date = "1986-12-14 14:18:59" INTERSECT SELECT shipping_agent_code, document_status_code, other_details, document_type_code, document_id, receipt_date, receipt_number FROM Documents WHERE other_details = "u" OR receipt_date != "1974-05-08 00:00:46"


Question: What are the employee IDs that are both equal to "1" and have a year awarded not equal to "2011" or a bonus less than or equal to 3000?

SELECT Employee_ID FROM evaluation WHERE Employee_ID = "1" INTERSECT SELECT Employee_ID FROM evaluation WHERE Year_awarded != "2011" OR "Bonus" <= 3000.0


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

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


Question: What are the ranks from the match results where the club ID is 3, combined with the ranks from players who are not sponsored by Saint Boniface and are not male, or whose name isn't Pat Martin, or whose occupation is retired, or who have at least 5490 votes, or whose rank isn't 1st and player ID is at least 6?

SELECT Rank FROM match_result WHERE "Club_ID" = 3 UNION ALL SELECT Rank FROM player WHERE Sponsor_name <> "Saint Boniface" AND Gender != "M" OR Player_name <> "Pat Martin" OR Occupation = "Retired" OR "Votes" >= 5490 OR Rank <> "1st" AND "Player_ID" >= 6


Question: What car makers are both "toyota" and not from country "6" with an ID other than 5, and also either "General Motors" or not "bmw", or with an ID other than 6 or not from country "4"?

SELECT Maker FROM car_makers WHERE Maker = "toyota" AND Country != "6" AND "Id" <> 5 INTERSECT SELECT Maker FROM car_makers WHERE FullName = "General Motors" OR Maker <> "bmw" OR "Id" <> 6 OR Country <> "4"


Question: What is the average gender from the coach table where the club ID is 3 or greater, or the gender is male, or the coach ID is greater than 1, combined with the average gender from the player table where the player ID is not 13, or the votes are 5502 or greater, or the gender is male, or the player name is not Ross Eadie?

SELECT AVG(Gender) FROM coach WHERE "Club_ID" >= 3 OR Gender = "M" OR "Coach_ID" > 1 UNION ALL SELECT AVG(Gender) FROM player WHERE "Player_ID" != 13 OR "Votes" >= 5502 OR Gender = "M" OR Player_name <> "Ross Eadie"


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

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


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

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


Question: What are the template type codes that are not "Paper", but are not "Book" and not "CV"?

SELECT Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Description != "Paper" EXCEPT SELECT Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Description != "Book" AND Template_Type_Code != "CV"


Question: What are the driver IDs that are either less than or equal to 4 in the driver table or greater than or equal to 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: Which driver IDs are equal to 6 but not equal to 3?

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


Question: Give me the sponsor name, gender, rank, player ID, and residence of players who are male, sponsored by Elmwood—Transcona, or ranked 1st, or not named Ross Eadie and not a Ministerial Assistant, or have a player ID that is not 4, but exclude those residing outside of Birtle, or are Ross Eadie and have a player ID of 10 or greater, or have 12093 votes.

SELECT Sponsor_name, Gender, Rank, Player_ID, Residence FROM player WHERE Gender = "M" OR Sponsor_name = "Elmwood—Transcona" OR Rank = "1st" OR Player_name != "Ross Eadie" AND Occupation <> "Ministerial Assistant" OR "Player_ID" != 4 EXCEPT SELECT Sponsor_name, Gender, Rank, Player_ID, Residence FROM player WHERE Residence != "Birtle" OR Player_name = "Ross Eadie" AND "Player_ID" >= 10 OR "Votes" = 12093


Question: Which driver IDs are equal to 12 but not present in the school bus records with driver IDs less than 7?

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


Question: What are the driver IDs that are less than 8 from the driver table, combined with 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 < 8 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 7


Question: What are the branch IDs, cities, names, street addresses, membership amounts, and opening years for branches that opened in 2009 and are not on Cecilia Avenue, as well as for branches named Cochrane with a membership amount of 56?

SELECT Branch_ID, City, Name, Address_road, membership_amount, Open_year FROM branch WHERE Open_year = "2009" AND Address_road <> "Cecilia Avenue" UNION ALL SELECT Branch_ID, City, Name, Address_road, membership_amount, Open_year FROM branch WHERE membership_amount = "56" AND Name = "Cochrane"


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

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


Question: What are the aircraft IDs that are both less than or equal to 5 in the aircraft table and less than 3 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 less than 11, and also the driver IDs from the school bus table that are not 9?

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


Question: What are the club ID, student ID, and position for members who are not in club 1 and have a student ID less than or equal to 1007, or who hold a position other than Vice-President? Also, what are the club ID, student ID, and position for members who are CTO and have a student ID less than or equal to 1008, but are not in club 1?

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


Question: What are the aircraft IDs that appear in the 'aircraft' table with an ID greater than or equal to 2, combined with the aircraft IDs from the 'airport_aircraft' table that are not equal to 3?

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


Question: What are the property type codes for "Shop, Retail Outlet." and "Other, to be determined."?

SELECT property_type_code FROM Ref_Property_Types WHERE property_type_description = "Shop, Retail Outlet." AND property_type_code = "Shop" UNION ALL SELECT property_type_code FROM Ref_Property_Types WHERE property_type_description = "Other, to be determined."


Question: What are the average dimensions, sum of max page sizes, color pages per minute, average DPI, product ID, product name, and sum of interfaces for products where the dimensions are not "289 x 51 x 38" or the max page size is not "216mm x 356mm" and the product ID is not 6 or the interface is not "USB 2.0" or the color pages per minute is 28.0? Also, what are the same statistics for products where the product ID is not 3 and the DPI is greater than 600 and the color pages per minute is less than 3, or the max page size is "216mm x 356mm" and the interface is not "USB 2.0"?

SELECT AVG(dimensions), SUM(max_page_size), pages_per_minute_color, AVG(dpi), product_id, product, SUM(interface) FROM product WHERE dimensions != "289 x 51 x 38" OR max_page_size != "216mm x 356mm" AND "product_id" != 6 OR interface != "USB 2.0" OR "pages_per_minute_color" = 28.0 UNION ALL SELECT AVG(dimensions), SUM(max_page_size), pages_per_minute_color, AVG(dpi), product_id, product, SUM(interface) FROM product WHERE "product_id" <> 3 AND "dpi" > 600.0 AND "pages_per_minute_color" < 3.0 OR max_page_size = "216mm x 356mm" AND interface != "USB 2.0"


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

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


Question: What are the driver IDs that are greater than or equal to 7, or any driver IDs that are not equal to 3?

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


Question: What are the aircraft IDs less than 5 that are not present in the airport_aircraft table with IDs greater than 2?

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


Question: What are the minimum and maximum budget invested percentages, the invested and budgeted amounts, and the school ID, considering the conditions specified in the budget table, and combine the results from two different sets of conditions?

SELECT MIN(total_budget_percent_invested), Invested, MAX(Budget_invested_percent), Budgeted, School_id FROM budget WHERE "total_budget_percent_budgeted" != 2.0 OR "Budgeted" <> 61283 OR "School_id" >= 3 AND "Year" != 2003 UNION SELECT MIN(total_budget_percent_invested), Invested, MAX(Budget_invested_percent), Budgeted, School_id FROM budget WHERE Budget_invested_percent <> "159.3" AND "Invested" = 8335 OR "total_budget_percent_budgeted" != 2.0


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

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


Question: What are the descriptions and codes of document types, excluding those with a description of "f" or a code of "Paper", and also including all document types that don't have the code "Hard Drive"?

SELECT document_type_description, document_type_code FROM Ref_Document_Types WHERE document_type_description <> "f" OR document_type_code != "Paper" UNION SELECT document_type_description, document_type_code FROM Ref_Document_Types WHERE document_type_code <> "Hard Drive"


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

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


Question: What are the driver IDs that are either 3 or greater, or less than 4, considering both drivers and school buses?

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 sums of Party and Name, the home city, age, and the minimum driver ID, considering drivers older than 45 or with a driver ID other than 2, combined with the same information for drivers who are not Democrats, not named Edwin Vargas, or have a driver ID other than 5, or are older than 37, or live in Manchester?

SELECT SUM(Party), SUM(Name), Home_city, Age, MIN(Driver_ID) FROM driver WHERE "Age" >= 46 OR "Driver_ID" != 2 UNION SELECT SUM(Party), SUM(Name), Home_city, Age, MIN(Driver_ID) FROM driver WHERE Party != "Dem" AND Name <> "Edwin Vargas" OR "Driver_ID" != 5 OR "Age" > 37 OR Home_city = "Manchester"


Question: What are the driver IDs greater than 6, and also the driver IDs that are less than or equal to 10?

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


Question: Which driver IDs are less than 7 but not equal to 9, considering only drivers and school buses?

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


Question: What are the IDs of all the pilots with an ID of 8 or higher who have a certificate, excluding those who have flown a flight that wasn't to Honolulu or flight number 76?

SELECT aid FROM certificate WHERE "aid" >= 8 EXCEPT SELECT aid FROM flight WHERE "flno" <> 76 OR destination != "Honolulu"


Question: What are the driver IDs that are either less than or equal to 10 from the 'driver' table or not equal to 7 from the 'school_bus' table?

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


Question: What are the IDs of airports that are not in Barcelona, have the ICAO code PANC, are in the United States, or don't have the IATA code ANC, and also have flight records where the airport ID isn't 4 or the velocity isn't 240?

SELECT id FROM airport WHERE City <> "Barcelona" OR ICAO = "PANC" OR Country = "United States" OR IATA != "ANC" INTERSECT SELECT id FROM flight WHERE "airport_id" != 4 OR "Velocity" != 240.0


Question: What are the driver IDs, excluding driver ID 4, and also the driver IDs greater than 3, from the driver and school bus tables?

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 aircraft IDs greater than 2 that are not present in the airport_aircraft table with aircraft IDs less than or equal to 3?

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


Question: What are the driver IDs, where the driver ID is 9 in the driver table or the driver ID is 3 in the school bus table?

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


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

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


Question: Which driver IDs are both greater than or equal to 4 in the driver table and equal to 10 in the school bus table?

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


Question: Which driver IDs are either 4 or not 7, considering driver and school bus information?

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


Question: Which driver IDs are greater than or equal to 5 but not present in the school bus table with driver IDs greater than or equal to 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: What is the average DPI, product ID, maximum page size, and color pages per minute, along with the minimum product name, for products where the product ID is less than 4, or the interface isn't USB 2.0, and the product isn't Xerox Travel Scanner 100, and the DPI is at least 600, and the color pages per minute is less than 10? Also, what is the average DPI, product ID, maximum page size, and color pages per minute, along with the minimum product name, for products where the dimensions aren't 280 x 95 x 40, and the color pages per minute is at least 30, and the maximum page size isn't 216mm x 355mm, or the product isn't ScanShell 3000DN, or the interface isn't USB 2.0, or the DPI is greater than 600?

SELECT AVG(dpi), product_id, max_page_size, pages_per_minute_color, MIN(product) FROM product WHERE "product_id" < 4 OR interface != "USB 2.0" AND product <> "Xerox Travel Scanner 100" AND "dpi" >= 600.0 AND "pages_per_minute_color" < 10.0 UNION SELECT AVG(dpi), product_id, max_page_size, pages_per_minute_color, MIN(product) FROM product WHERE dimensions <> "280 x 95 x 40" AND "pages_per_minute_color" >= 30.0 AND max_page_size <> "216mm x 355mm" OR product != "ScanShell 3000DN" AND interface <> "USB 2.0" OR "dpi" > 600.0


Question: What are the aircraft IDs that appear in both the aircraft table with an ID less than or equal to 3 and the airport_aircraft table with an ID of 2?

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


Question: What are the driver IDs greater than 9 who are not assigned to a school bus, excluding driver ID 4?

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: Which driver IDs are not equal to 9 and are not present in the school bus table, excluding those with a driver ID of 10?

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


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

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


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

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


Question: What is the maximum value of 'Is_full_time' considering employees who are not in shop 1 or not employee 7 or are part-time, combined with the maximum value of 'Is_full_time' for employees who are not employee 2 and started before 2003 or are not in shop 1 or are not full-time, all from the hiring table?

SELECT MAX(Is_full_time) FROM hiring WHERE "Shop_ID" <> 1 OR "Employee_ID" <> 7 OR Is_full_time = "F" UNION SELECT MAX(Is_full_time) FROM hiring WHERE "Employee_ID" != 2 AND Start_from <> "2003" OR "Shop_ID" <> 1 OR Is_full_time != "T"


Question: What are the document IDs from the drafts where the draft details aren't "r" or the document ID is less than or equal to 4, combined with the document IDs from the documents where the other details aren't "h" or the shipping agent code isn't "SH" and the receipt date is "1985-11-05 17:59:34" and the document ID is greater than or equal to 12?

SELECT document_id FROM Document_Drafts WHERE draft_details <> "r" OR "document_id" <= 4 UNION ALL SELECT document_id FROM Documents WHERE other_details != "h" OR shipping_agent_code <> "SH" AND receipt_date = "1985-11-05 17:59:34" AND "document_id" >= 12


Question: What are the driver IDs greater than 4 that are present in both the driver and school bus tables, 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: Which driver IDs are greater than 2 but not greater than 9, considering only the driver IDs present in the driver table and excluding those in the school bus table?

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


Question: What is the sum of 'Start_from' and the maximum 'Is_full_time', grouped by 'Employee_ID', either when 'Shop_ID' is not 6 or 'Start_from' is "2010", or when 'Employee_ID' is less than or equal to 1, or 'Start_from' is not "2003" and 'Is_full_time' is not "F", using data from the 'hiring' table?

SELECT SUM(Start_from), MAX(Is_full_time), Employee_ID FROM hiring WHERE "Shop_ID" != 6 OR Start_from = "2010" UNION SELECT SUM(Start_from), MAX(Is_full_time), Employee_ID FROM hiring WHERE "Employee_ID" <= 1 OR Start_from != "2003" AND Is_full_time != "F"


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

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


Question: What is the average student ID of students with IDs 1001 or greater, excluding the average student ID of students who are not male, or whose first name isn't Jandy, and also excluding students with advisors numbered 1148 or less and age 26 or less, or students with major codes 600 or less and not living in Boston?

SELECT AVG(StuID) FROM Has_Pet WHERE "StuID" >= 1001 EXCEPT SELECT AVG(StuID) FROM Student WHERE Sex != "M" OR Fname <> "Jandy" AND "Advisor" <= 1148 AND "Age" <= 26 OR "Major" <= 600 AND city_code <> "BOS"


Question: What are the district IDs where the city area is less than or equal to 25, or the district name is not Gujranwala District, and the district ID is not 9, and the city population is less than or equal to 134936, but not including those district IDs that have a store ID greater than 2 and a district ID less than 4?

SELECT District_ID FROM district WHERE "City_Area" <= 25.0 OR District_name != "Gujranwala District" AND "District_ID" != 9 AND "City_Population" <= 134936.0 EXCEPT SELECT District_ID FROM store_district WHERE "Store_ID" > 2 AND "District_ID" < 4


Question: What car makers are not Honda and not from country "2", or what car makers have a model that isn't "pontiac" or a model ID that isn't 14 or a maker ID less than 20?

SELECT Maker FROM car_makers WHERE FullName != "Honda" AND Country != "2" UNION SELECT Maker FROM model_list WHERE Model <> "pontiac" OR "ModelId" != 14 OR "Maker" < 20


Question: What is the average property ID from the 'Other_Property_Features' table where the feature ID is less than 2, combined with the average property ID from the 'Properties' table where the agreed selling price is not 476919.3, or fld_feature_2 is not "None", or the property ID is not 3 and fld_feature_1 is "None", or the property type code is not "Apartment" and apt_feature_3 is "None" and hse_feature_1 is "None", or hse_feature_3 is not "None", or apt_feature_2 is "est" and shp_feature_2 is "None" and other_property_details is not "None", or fld_feature_3 is not "None", or the buyer offered price is 8.7122, or hse_feature_2 is not "None", or oth_feature_2 is "None", or shp_feature_3 is "None"?

SELECT AVG(property_id) FROM Other_Property_Features WHERE "feature_id" < 2 UNION ALL SELECT AVG(property_id) FROM Properties WHERE "agreed_selling_price" != 476919.3 OR fld_feature_2 != "None" OR "property_id" != 3 AND fld_feature_1 = "None" OR property_type_code <> "Apartment" AND apt_feature_3 = "None" AND hse_feature_1 = "None" OR hse_feature_3 <> "None" OR apt_feature_2 = "est" AND shp_feature_2 = "None" AND other_property_details != "None" OR fld_feature_3 <> "None" OR "buyer_offered_price" = 8.7122 OR hse_feature_2 <> "None" OR oth_feature_2 = "None" OR shp_feature_3 = "None"


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

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


Question: What driver IDs are present in both the driver table, excluding ID 10, and the school bus table, specifically with ID 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 document status descriptions are "mailed late" and also either "mailed late" or not "overdue"?

SELECT document_status_description FROM Ref_Document_Status WHERE document_status_description = "mailed late" INTERSECT SELECT document_status_description FROM Ref_Document_Status WHERE document_status_description = "mailed late" OR document_status_code != "overdue"


Question: What is the minimum number of total passengers and the corresponding airport ID?

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


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

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


Question: What are the driver IDs greater than 8, combined with the driver IDs from school buses that are 7 or less?

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 appear in the aircraft table with an ID of 5 or greater, but are not in the airport_aircraft table with an ID of 2 or less?

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 driver IDs greater than 1 who are not driver IDs that are not equal to 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: Which driver IDs are greater than 7 but not present in the school bus table with IDs greater than or equal to 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 are the driver IDs that are equal to 8, excluding those with driver IDs greater than 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: Which driver IDs are 2 or 3?

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


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

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


Question: What are all the document type codes, either from documents that don't have receipt number "124" or have a document ID of 2, or from document types that aren't "Paper" or don't have a description of "b"?

SELECT document_type_code FROM Documents WHERE receipt_number != "124" OR "document_id" = 2 UNION ALL SELECT document_type_code FROM Ref_Document_Types WHERE document_type_code <> "Paper" OR document_type_description <> "b"


Question: What are the aircraft IDs that are not equal to 2, but are not also aircraft IDs less than 5 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 trust, source user ID, and target user ID values exist where the target user ID is greater than 3, and also where either the source user ID is not 3, the trust value is not 10, or the target user ID is less than 3?

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


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

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


Question: What are the driver IDs greater than 7, and also the driver IDs from school buses that are not 3?

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


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

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


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

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


Question: What are the driver IDs greater than 6, and also the driver IDs from school buses that are not 10?

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


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

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


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

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


Question: What is the maximum home city for drivers who live in Hartford, are Democrats, or are named Matthew Ritter, combined with the maximum home city for drivers who don't live in Hartford and aren't Democrats?

SELECT MAX(Home_city) FROM driver WHERE Home_city = "Hartford" OR Party = "Dem" OR Name = "Matthew Ritter" UNION SELECT MAX(Home_city) FROM driver WHERE Home_city <> "Hartford" AND Party <> "Dem"


Question: What are the driver IDs that are either greater than or equal to 12, or not equal to 4, considering driver and school bus information?

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


Question: What is the average city value for employees who are not 43 years old, or live in Bath and are not Steve Borthwick and have an employee ID less than or equal to 7, combined with the average city value for employees named Tim Payne, or are older than 43, or have an employee ID of 3?

SELECT AVG(City) FROM employee WHERE "Age" != 43 OR City = "Bath" AND Name != "Steve Borthwick" AND "Employee_ID" <= 7 UNION SELECT AVG(City) FROM employee WHERE Name = "Tim Payne" OR "Age" > 43 OR "Employee_ID" = 3


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

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


Question: What are the driver IDs that are less than 6, and also the driver IDs that are less than or equal to 7, considering both the driver and school bus information?

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


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

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


Question: What are the member IDs of members who have a level greater than 4, or whose name isn't Jeremy Jarmon, or whose hometown isn't Louisville, Kentucky, and also the member IDs from the branch register for the year 2017 where the branch ID isn't 2 and the member ID is greater than 2?

SELECT Member_ID FROM member WHERE "Level" > 4 OR Name != "Jeremy Jarmon" OR Hometown <> "Louisville, Kentucky" UNION ALL SELECT Member_ID FROM membership_register_branch WHERE Branch_ID <> "2" AND Register_Year = "2017" AND "Member_ID" > 2


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

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 are the driver IDs that are greater than or equal to 1, excluding those driver IDs that are not equal to 7 and appear in the school bus records?

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 aircraft IDs, excluding ID 1, that are in the aircraft table, combined with the aircraft IDs, excluding ID 3, that are in the airport_aircraft table?

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


Question: What are the aircraft IDs that are equal to 4 in the aircraft table, but not 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: How many pets and the minimum student ID are there where the pet ID is 2002 or greater, or the student ID is not 1002, but exclude the count and minimum student ID where the student ID is not 1001 and the pet ID is not 2002?

SELECT COUNT(PetID), MIN(StuID) FROM Has_Pet WHERE "PetID" >= 2002 OR "StuID" <> 1002 EXCEPT SELECT COUNT(PetID), MIN(StuID) FROM Has_Pet WHERE "StuID" <> 1001 AND "PetID" <> 2002


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

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


Question: What are the average values of Writer, Issues, and Title, excluding books where Issues is 4.0, Writer is Elaine Lee, or Title is "The Dome: Ground Zero", and also what are the average values of Writer, Issues, and Title for books with a title other than "BrainBanx" and a Book_ID less than or equal to 6?

SELECT AVG(Writer), AVG(Issues), AVG(Title) FROM book WHERE "Issues" <> 4.0 AND Writer <> "Elaine Lee" AND Title <> "The Dome: Ground Zero" UNION SELECT AVG(Writer), AVG(Issues), AVG(Title) FROM book WHERE Title != "BrainBanx" AND "Book_ID" <= 6


Question: What are the aircraft IDs that appear in both the aircraft and airport_aircraft tables, where the aircraft ID is greater than or equal to 3?

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


Question: What car models are both a "plymouth horizon miser" or have a MakeId of 32 and are not "fiat"?

SELECT Model FROM car_names WHERE Make = "plymouth horizon miser" OR "MakeId" = 32 INTERSECT SELECT Model FROM model_list WHERE Model != "fiat"


Question: What is the lowest store ID among stores that have more than 1678 product categories and are not "Village Stores", and also among stores where the store ID is less than or equal to 2 or the product ID is less than or equal to 2?

SELECT MIN(Store_ID) FROM store WHERE "Number_of_product_category" > 1678.0 AND Type <> "Village Store" INTERSECT SELECT MIN(Store_ID) FROM store_product WHERE "Store_ID" <= 2 OR "Product_ID" <= 2


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

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


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

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


Question: Which driver IDs are greater than 4 in the driver table, or equal to 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 aircraft IDs that are not equal to 1 and exist in the aircraft table but are not equal to 1 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 = 1


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

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


Question: What are the driver IDs from the driver table that are 8 or less, combined with the driver IDs from the school bus table that are 10 or less?

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


Question: What are the aircraft IDs, excluding aircraft ID 4, and also the aircraft IDs that are less than or equal to 2?

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


Question: Which driver IDs are not 7, and which driver ID is 4, considering both drivers and 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 = 4


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

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


Question: What are the receipt date, shipping agent code, other details, minimum document status code, receipt number, and average document ID for documents where the receipt number is "61", the receipt date is "2015-04-03 09:36:19", the shipping agent code is not "UP" and the document status code is not "working", the other details are "n", or the document ID is not 4? Also, what are the same details for documents where the receipt number is not "83", the other details are not "y", the shipping agent code is not "FE", the document ID is not 12, and the document type code is not "Paper"?

SELECT receipt_date, shipping_agent_code, other_details, MIN(document_status_code), receipt_number, AVG(document_id) FROM Documents WHERE receipt_number = "61" OR receipt_date = "2015-04-03 09:36:19" OR shipping_agent_code != "UP" AND document_status_code != "working" OR other_details = "n" OR "document_id" != 4 UNION SELECT receipt_date, shipping_agent_code, other_details, MIN(document_status_code), receipt_number, AVG(document_id) FROM Documents WHERE receipt_number <> "83" OR other_details != "y" OR shipping_agent_code <> "FE" AND "document_id" != 12 AND document_type_code <> "Paper"


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

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


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

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


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

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


Question: What are the overdue document status codes for documents with "r" as other details and a receipt date not equal to "2017-07-02 17:39:09", excluding those with a "done" status?

SELECT document_status_code FROM Documents WHERE other_details = "r" AND receipt_date <> "2017-07-02 17:39:09" AND document_status_code = "overdue" EXCEPT SELECT document_status_code FROM Ref_Document_Status WHERE document_status_code = "done"


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

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


Question: Which driver IDs are in either the driver table (excluding driver ID 9) or the school bus table (with driver IDs 4 or greater)?

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


Question: What are the document IDs of items with a copy number greater than 4 that also have a receipt number that is not "114" or a document type code that is not "CD"?

SELECT document_id FROM Circulation_History WHERE "copy_number" > 4 INTERSECT SELECT document_id FROM Documents WHERE receipt_number <> "114" OR document_type_code <> "CD"


Question: Which driver IDs are both equal to 10 and greater than 3, considering the drivers and school buses?

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


Question: What is the minimum ICAO code, name, city, and IATA code for airports that either have an ICAO code of KBOS and are located in Akureyri, or have a name other than "El Prat Airport" and a different IATA code than BWI, or have an ID greater than 6? Also, what is the minimum ICAO code, name, city, and IATA code for airports that are not named "Baltimore-Washington Airport"?

SELECT MIN(ICAO), name, City, IATA FROM airport WHERE Country != "Netherlands" AND ICAO = "KBOS" AND City = "Akureyri" OR name != "El Prat Airport" AND IATA <> "BWI" OR "id" > 6 UNION SELECT MIN(ICAO), name, City, IATA FROM airport WHERE name <> "Baltimore-Washington Airport"


Question: Which driver IDs are not equal to 6 and are present in the driver table but not in the school bus table, where the school bus table only includes driver IDs greater than or equal to 3?

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


Question: What are the driver IDs that are either 6 or not 10?

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


Question: What are the aircraft IDs that are equal to 1, but not equal to 5, considering the aircraft and airport aircraft information?

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


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

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


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

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


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

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


Question: Which driver IDs, excluding ID 3, are present in both the driver and school bus tables?

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


Question: What are the aircraft IDs that are either less than or equal to 3 from the aircraft table, or not equal to 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 greater than 9 that are in the driver table but not in the school bus table, where the driver IDs in the school bus table are greater than 10?

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


Question: What are the IDs of heads who are either not from Florida and are age 68 or less, or whose name isn't Dudley Hart, or are age 68, and are also temporarily acting?

SELECT head_ID FROM head WHERE "head_ID" <= 9 AND born_state != "Florida" OR name <> "Dudley Hart" OR "age" = 68.0 INTERSECT SELECT head_ID FROM management WHERE temporary_acting <> "No"


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

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


Question: What are the aircraft IDs that are either less than or equal to 4 in the aircraft table, or not equal to 1 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 <> 1


Question: What are the user IDs of reviewers who gave a 5-star rating to article 5 or rated an article over 10, combined with the user IDs of users with IDs less than or equal to 3?

SELECT u_id FROM review WHERE "a_id" = 5 AND "rank" = 5 OR "rating" > 10 UNION SELECT u_id FROM useracct WHERE "u_id" <= 3


Question: What is the average branch ID and sum of member IDs for the year 2016 and member ID 3 in the membership register, excluding the average branch ID and sum of member IDs from purchases where the total pounds is not 232.09 and the branch ID is 6, or the member ID is not 3?

SELECT AVG(Branch_ID), SUM(Member_ID) FROM membership_register_branch WHERE Register_Year = "2016" AND "Member_ID" = 3 EXCEPT SELECT AVG(Branch_ID), SUM(Member_ID) FROM purchase WHERE "Total_pounds" <> 232.09 AND Branch_ID = "6" OR "Member_ID" <> 3


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

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, excluding driver 5, are present in both the driver and school bus tables, excluding driver 4?

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


Question: What are the driver IDs that are not 6 and are also present in the school bus table with driver ID 4?

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


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

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


Question: Which driver IDs are equal to 4 but not greater than 4, considering driver information and school bus information?

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: Which driver IDs are greater than 10 but not equal to 9, considering only those present in the driver table but not 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 != 9


Question: What are the driver IDs of drivers who are Democrats or named Brandon McGee, along with the driver IDs of school buses with a school ID of 7 or less?

SELECT Driver_ID FROM driver WHERE Party = "Dem" OR Name = "Brandon McGee" UNION ALL SELECT Driver_ID FROM school_bus WHERE "School_ID" <= 7


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

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


Question: What are the IDs of pets that either belong to students with IDs less than or equal to 1002 or have pet IDs greater than or equal to 2001, or weigh 12.0 or less?

SELECT PetID FROM Has_Pet WHERE "StuID" <= 1002 OR "PetID" >= 2001 UNION SELECT PetID FROM Pets WHERE "weight" <= 12.0


Question: What are the IDs of airports in Iceland or airports not named "El Prat Airport" and not having IATA code "BWI", that are also IDs of flights where the velocity isn't 240.0, the flight ID isn't 10, or the company ID is less than 9 and the date is October 8, 1965, or the pilot isn't Peterson?

SELECT id FROM airport WHERE Country = "Iceland" OR name != "El Prat Airport" AND IATA != "BWI" INTERSECT SELECT id FROM flight WHERE "Velocity" != 240.0 AND "id" != 10 OR "company_id" < 9 AND Date = "October 8, 1965" OR Pilot != "Peterson"


Question: What is the maximum customer ID and customer status code for customers who paid via Direct Debit on February 15, 2018, at 4:38:49 PM, and whose phone number is 1-875-045-0806, or whose email is myrl.lind@example.net and became a customer on June 24, 2015, or whose payment amount was less than or equal to 1708.18, or whose first name is Estelle, or whose cell phone number is (630)964-2426, or whose customer address ID is not 13 and date of birth is November 7, 1996?

SELECT MAX(T1.customer_id), T2.customer_status_code FROM Customer_Payments as T1 JOIN Customers as T2 ON T1.customer_id = T2.customer_id WHERE payment_method_code = "Direct Debit" AND datetime_payment = "2018-02-15 16:38:49" AND phone_number = "1-875-045-0806" OR email_address = "myrl.lind@example.net" AND date_became_customer = "2015-06-24 03:50:04" AND "amount_payment" <= 1708.18 OR first_name = "Estelle" OR cell_mobile_phone_number = "(630)964-2426" OR "customer_address_id" <> 13 AND date_of_birth = "1996-11-07 05:30:55"


Question: What are the driver IDs that are both less than 11 and present in the school bus records, excluding driver ID 9?

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


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

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


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

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


Question: What are the driver IDs, excluding driver ID 1, and also any driver IDs from school buses that are 7 or less?

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


Question: Which aircraft IDs are greater than 2 but not equal to 3, considering only the aircraft IDs present in the aircraft table and excluding those in the airport_aircraft table?

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


Question: What are the driver IDs, excluding ID 6, from the driver table and the driver IDs, excluding ID 10, from the school bus table, combined into a single list?

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


Question: What are the product numbers, names, and locations of shops not managed by Tommi Kautonen, excluding those with a shop ID other than 8 and managed by Pekka Lyyski, or located in Espoo with 10770 products and not in the Finnair Stadium, and not named HJK?

SELECT Number_products, Name, Location FROM shop WHERE Manager_name != "Tommi Kautonen" EXCEPT SELECT Number_products, Name, Location FROM shop WHERE "Shop_ID" <> 8 AND Manager_name = "Pekka Lyyski" OR Location = "Espoo" AND "Number_products" = 10770 AND District <> "Finnair Stadium" AND Name != "HJK"


Question: What are the color pages per minute, dimensions, interface, max page size, and product for products where the dimensions are not "280 x 95 x 40" or the interface is "USB 2.0" or the product ID is greater than or equal to 1, and also for products where the color pages per minute is less than 10.0, the dimensions are "289 x 51 x 38", and the interface is "USB 2.0" or the product is "ScanShell 3000DN"?

10
280 x 95 x 40
USB 2.0
216mm x 356mm
Canon imageFORMULA P-150

SELECT pages_per_minute_color, dimensions, interface, max_page_size, product FROM product WHERE dimensions <> "280 x 95 x 40" OR interface = "USB 2.0" OR "product_id" >= 1 UNION ALL SELECT pages_per_minute_color, dimensions, interface, max_page_size, product FROM product WHERE "pages_per_minute_color" < 10.0 AND dimensions = "289 x 51 x 38" AND interface = "USB 2.0" OR product = "ScanShell 3000DN"


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

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


Question: What is the sum of the names from the company table where the name is "Industrial and Commercial Bank of China", intersected with the sum of names from the people table where the age is less than 30, the name is not "Tom Sheehey", and the graduation college is not "Virginia"?

SELECT SUM(Name) FROM company WHERE Name = "Industrial and Commercial Bank of China" INTERSECT SELECT SUM(Name) FROM people WHERE "Age" < 30 AND Name != "Tom Sheehey" AND Graduation_College <> "Virginia"


Question: What is the average club ID for clubs that started in a year other than 2009, or have a club ID less than or equal to 2, or are not in Russia and are not named BK Häcken? Also, what is the average club ID for coaches who are not named Joe Fabbri and do not have a coach ID of 1?

SELECT AVG(Club_ID) FROM club WHERE "Start_year" != 2009 OR "Club_ID" <= 2 OR Region != "Russia" AND Club_name <> "BK Häcken" UNION ALL SELECT AVG(Club_ID) FROM coach WHERE Coach_name <> "Joe Fabbri" AND "Coach_ID" <> 1


Question: What are the IDs from the airport and flight tables where the city is Akureyri, the company ID is less than 2, the airport name is not Ted Stevens Airport, the IATA code is BCN, and the vehicle flight number is M2-F1 #61, or the velocity is at least 240.0 and the airport ID is not 3, or the pilot is Thompson and the altitude is at most 3650.0, or the country is Netherlands and the ICAO code is LEBL?

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


Question: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 4 from the driver table and driver IDs 4 and above from 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 >= 4


Question: What are the driver IDs that are either less than or equal to 12 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 <= 12 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 10


Question: What are the driver IDs that are both less than or equal to 11 and also appear in the school bus table with IDs less than 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 both greater than or equal to 9 and also not equal to 3, considering only the driver IDs present in both the driver and school bus tables?

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


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

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


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

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


Question: What are the last names, average ages, majors, and city codes of students named Derek with major 600, and also the last names, average ages, majors, and city codes of all students not from PIT?

SELECT LName, AVG(Age), Major, city_code FROM Student WHERE Fname = "Derek" AND "Major" = 600 UNION ALL SELECT LName, AVG(Age), Major, city_code FROM Student WHERE city_code != "PIT"


Question: What are the budget amounts in billions for departments, excluding those with a budget of 543.2, that meet at least one of the following conditions: department ID is 5 or less, the name isn't "Energy", the ranking is 15 or higher, or the creation year is 1913? Also, exclude any budget amounts that are from departments that don't have a ranking of 1, or have more than 235,000 employees and a name that is not "Health and Human Services", and a budget of 21.5 or less.

SELECT Budget_in_Billions FROM department WHERE "Department_ID" <= 5 OR Name <> "Energy" OR "Ranking" >= 15 OR Creation = "1913" GROUP BY Budget_in_Billions HAVING Budget_in_Billions <> 543.2 EXCEPT SELECT Budget_in_Billions FROM department WHERE "Ranking" != 1 OR "Num_Employees" > 235000.0 AND Name != "Health and Human Services" GROUP BY Budget_in_Billions HAVING Budget_in_Billions <= 21.5


Question: What are the aircraft IDs that are equal to 5 in the aircraft table, but not aircraft IDs 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: Which driver IDs are both less than or equal to 6 and present in the school bus table, and also equal to 4?

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


Question: What are the copy number, document ID, and employee ID for circulation history entries where the draft number is 17 or less, and also for entries where the draft number is not 2, or the copy number is not 10, or the employee ID is not 8?

SELECT copy_number, document_id, employee_id FROM Circulation_History WHERE "draft_number" <= 17 UNION ALL SELECT copy_number, document_id, employee_id FROM Circulation_History WHERE "draft_number" != 2 OR "copy_number" <> 10 OR "employee_id" != 8


Question: What are the aircraft details, including maximum disk loading, description, ID, total disk area, and maximum gross weight, for aircraft that are either a Robinson R-22, or have an ID other than 5, or are described as a heavy-lift helicopter, and also for aircraft that are either a CH-53E Super Stallion, or have an ID of 5 or greater, or have a maximum disk loading different from 2.6 lb/ft² (14 kg/m²), or have a maximum gross weight of 1,370 lb (635 kg), excluding those with a total disk area of 497 ft² (46.2 m²) and not described as a heavy-lift helicopter?

Bell 206B3 JetRanger
3.7 lb/ft² (18 kg/m²)
Turboshaft utility helicopter
2
872 ft² (81.1 m²)
3,200 lb (1,451 kg)

CH-47D Chinook
8.8 lb/ft² (43 kg/m²)
Tandem rotor helicopter
3
5,655 ft² (526 m²)
50,000 lb (22,680 kg)

CH-53E Super Stallion
15 lb/ft² (72 kg/m²)
Heavy-lift helicopter
5
4,900 ft² (460 m²)
73,500 lb (33,300 kg)

Robinson R-22
2.6 lb/ft² (14 kg/m²)
Light utility helicopter
1
497 ft² (46.2 m²)
1,370 lb (635 kg)

SELECT Aircraft, Max_disk_Loading, Description, Aircraft_ID, Total_disk_area, Max_Gross_Weight FROM aircraft WHERE Max_Gross_Weight != "73,500 lb (33,300 kg)" AND Total_disk_area <> "872 ft² (81.1 m²)" AND Aircraft = "Robinson R-22" OR "Aircraft_ID" <> 5 OR Description = "Heavy-lift helicopter" INTERSECT SELECT Aircraft, Max_disk_Loading, Description, Aircraft_ID, Total_disk_area, Max_Gross_Weight FROM aircraft WHERE Aircraft = "CH-53E Super Stallion" OR "Aircraft_ID" >= 5 OR Max_disk_Loading <> "2.6 lb/ft² (14 kg/m²)" AND Description != "Heavy-lift helicopter" AND Total_disk_area <> "497 ft² (46.2 m²)" OR Max_Gross_Weight = "1,370 lb (635 kg)"


Question: What are the driver IDs that are either greater than or equal to 3 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 >= 3 UNION SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <= 9


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

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


Question: What are the aircraft IDs that are not equal to 5, excluding those aircraft IDs that are greater than or equal to 3 and are also present 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: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 3 or higher?

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


Question: For each city, excluding those where the youngest employee is 29, give me the sum of employee IDs, the number of employees, the minimum age, and the city itself. Then, from the cities where the number of employees isn't 1, or the sum of employee IDs isn't 13, or the youngest employee is under 23, give me the same information. Finally, show only the cities that appear in both of these sets of results.

SUM(Employee_ID) COUNT(Name) MIN(Age) City

SELECT SUM(Employee_ID), COUNT(Name), MIN(Age), City FROM employee GROUP BY City HAVING MIN(Age) <> 29 INTERSECT SELECT SUM(Employee_ID), COUNT(Name), MIN(Age), City FROM employee GROUP BY City HAVING COUNT(Name) != 1 OR SUM(Employee_ID) != 13 OR MIN(Age) < 23


Question: What are the IDs of drivers, excluding driver 8, and the IDs of school buses, excluding bus 4?

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


Question: What are the document IDs from draft documents with draft number greater than 9 and draft details equal to "l", excluding document ID 17, and also the document IDs from mailed documents sent on November 4th, 2010, to an address ID of 7 or less, excluding document ID 23?

SELECT document_id FROM Document_Drafts WHERE "draft_number" > 9 AND draft_details = "l" AND "document_id" != 17 UNION ALL SELECT document_id FROM Documents_Mailed WHERE mailing_date = "2010-11-04 04:00:16" AND "mailed_to_address_id" <= 7 AND "document_id" <> 23


Question: What are the school IDs for schools in Walkerton that are not named Triton, don't have the Cavaliers mascot, and are in the AAA IHSAA class, or have enrollment not equal to 379 and are not in the AAA IHSAA football class and don't have school ID 5, or are in Marshall county? Also, what are the school IDs from the endowment table where the school ID is greater than or equal to 2, or the endowment ID is greater than or equal to 9, or the donator name is not "Com. Dom. En Estados Unidos" and the amount is greater than 9.51?

SELECT School_id FROM School WHERE School_name <> "Triton" AND Mascot <> "Cavaliers" AND Location = "Walkerton" AND IHSAA_Class = "AAA" OR "Enrollment" <> 379 AND IHSAA_Football_Class != "AAA" AND School_id <> "5" OR County = "50 Marshall" UNION ALL SELECT School_id FROM endowment WHERE "School_id" >= 2 OR "endowment_id" >= 9 OR donator_name <> "Com. Dom. En Estados Unidos" AND "amount" > 9.51


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

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


Question: What are the driver IDs of Matthew Ritter who are not from Hartford and are Democrats, combined with the driver IDs of school buses where the school ID is not 3 and the driver is not full-time, or has worked less than 2 years, or the driver ID is 3 or greater?

SELECT Driver_ID FROM driver WHERE Name = "Matthew Ritter" AND Home_city != "Hartford" AND Party = "Dem" UNION ALL SELECT Driver_ID FROM school_bus WHERE "School_ID" != 3 AND If_full_time <> "T" OR "Years_Working" < 2 OR "Driver_ID" >= 3


Question: Give me the names, head IDs, and birth states of people from the head table where the head ID is greater than 6, or they were born in Florida, and their name is Stewart Cink, and their age is not 69.0, but exclude any information about the person with head ID 2.

SELECT name, head_ID, born_state FROM head WHERE "head_ID" > 6 OR born_state = "Florida" AND name = "Stewart Cink" AND "age" <> 69.0 EXCEPT SELECT name, head_ID, born_state FROM head WHERE "head_ID" = 2


Question: What are the IDs of drivers who are either not driver ID 1 in the driver table or not driver ID 9 in the school bus table?

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


Question: What are the names of female coaches, excluding those who are not ranked 2, are not male, have the name "James Wong", and have a club ID less than 1 and a coach ID greater than 5?

SELECT Coach_name FROM coach WHERE Gender = "F" EXCEPT SELECT Coach_name FROM coach WHERE "Rank" <> 2 AND Gender != "M" AND Coach_name = "James Wong" AND "Club_ID" < 1 AND "Coach_ID" > 5


Question: What are the driver IDs, excluding driver ID 3, and also driver IDs that are 4 or greater, from the driver and school bus tables?

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


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

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


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

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


Question: What are the city areas and district names that satisfy either of these conditions: the district name is Jhang District, the city population is less than 219254, or the district ID is 7 and the headquartered city is not Bhakkar City; and also have a city area greater than or equal to 10?

SELECT City_Area, District_name FROM district WHERE District_name = "Jhang District" OR "City_Population" < 219254.0 OR "District_ID" = 7 AND Headquartered_City <> "Bhakkar City" INTERSECT SELECT City_Area, District_name FROM district WHERE "City_Area" >= 10.0


Question: What are the aircraft IDs that are either greater than or equal to 5, or equal to 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 driver IDs that are either less than or equal to 2 in the driver table, or less than 7 in the school bus table?

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


Question: Which customer IDs meet at least one of the following conditions: their payment date is not "2018-02-19 01:49:59" or their customer ID is 3 or greater; or they became a customer on a date other than "2015-09-25 13:59:21" and their first name is Omer, or their customer ID is 11 or less, or their date of birth is not "1996-05-23 01:21:54" and their customer address ID is not 2, or their amount outstanding is not 2255.0, or their customer status code is not "Bad Customer" and their last name is Spinka?

SELECT customer_id FROM Customer_Payments WHERE "customer_id" >= 3 OR datetime_payment != "2018-02-19 01:49:59" UNION SELECT customer_id FROM Customers WHERE date_became_customer <> "2015-09-25 13:59:21" AND first_name = "Omer" OR "customer_id" <= 11 OR date_of_birth != "1996-05-23 01:21:54" AND "customer_address_id" != 2 OR "amount_outstanding" != 2255.0 OR customer_status_code <> "Bad Customer" AND last_name = "Spinka"


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

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


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

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


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

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


Question: What are the aircraft IDs that are both greater than or equal to 2 and less than or equal to 3, considering only aircraft and airport-aircraft data?

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


Question: Which driver IDs are greater than or equal to 5, excluding driver ID 10?

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


Question: Which driver IDs are not equal to 1 but are not associated with a school bus with a driver ID greater than 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: Which driver IDs are greater than 11 but not found in the school bus table with IDs greater than or equal to 4?

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


Question: Which driver IDs, excluding driver ID 11, are in the driver table but not in the school bus table, excluding 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 is the total number of car makers and the horsepower for cars with more than 4 cylinders and not 105 horsepower, or with acceleration greater than or equal to 18.0?

SELECT SUM(T1.Id), T2.Horsepower FROM car_makers as T1 JOIN cars_data as T2 ON T1.Id = T2.Id WHERE "Cylinders" > 4 AND Horsepower <> "105" OR "Accelerate" >= 18.0


Question: Which driver IDs are equal to 11 but not less than or equal to 9, considering driver IDs from the driver and school bus tables?

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


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

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


Question: What are the driver IDs that are less than 9, and also the driver IDs from school buses that are 7 or greater?

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


Question: What is the sum of Company IDs for people who worked in the first year, and also the sum of Company IDs for people where the Company ID is not 17 or the People ID is greater than 7, showing the People ID in both cases?

SELECT SUM(Company_ID), People_ID FROM employment WHERE "Year_working" = 1 UNION ALL SELECT SUM(Company_ID), People_ID FROM employment WHERE "Company_ID" <> 17 OR "People_ID" > 7


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

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


Question: What are the driver IDs greater than 3 that are not also driver IDs from school buses with IDs less than or equal to 10?

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


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

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


Question: Which driver IDs are present in both the driver table (excluding driver ID 11) and the school bus table (with driver ID 3)?

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


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

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


Question: What are the aircraft IDs that are less than or equal to 2, excluding those aircraft IDs that are greater than or equal to 5?

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