Question: What are the aircraft IDs that are both greater than or equal to 3 and also 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: Which driver IDs are not equal to 2 but are not also driver IDs for school buses with driver ID 9?

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


Question: What are the aircraft IDs that are not 4, and also the aircraft IDs that are 3 or less, considering both the aircraft and airport_aircraft tables?

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


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

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


Question: What are the driver IDs that are less than 11, and also the driver ID 4?

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


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

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


Question: Which driver IDs, excluding driver ID 1, are present in both the driver and school bus tables, and where the school bus table specifically has driver ID 7?

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


Question: What are the driver IDs, excluding ID 9, that are 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 <> 9


Question: Which member IDs and branch IDs are associated with branches other than branch 6, and also which member IDs and branch IDs are associated with purchases where the member ID is 2 or less?

SELECT Member_ID, Branch_ID FROM membership_register_branch WHERE Branch_ID <> "6" UNION SELECT Member_ID, Branch_ID FROM purchase WHERE "Member_ID" <= 2


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

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


Question: What are the names of aircraft and their total distances, excluding Airbus A340-300 if the distance is not 30, and also excluding British Aerospace Jetstream 41 if the distance is less than or equal to 6475 and aid is 8, where the total distance is no more than 8430 or not equal to 4103, respectively?

SELECT name, SUM(distance) FROM aircraft WHERE name != "Airbus A340-300" OR "distance" = 30 GROUP BY name HAVING SUM(distance) <= 8430 UNION SELECT name, SUM(distance) FROM aircraft WHERE "distance" <= 6475 AND "aid" = 8 AND name <> "British Aerospace Jetstream 41" GROUP BY name HAVING SUM(distance) <> 4103


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

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


Question: Which driver IDs are not 4, and which driver ID is 9, considering both drivers and school buses?

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


Question: What are the aircraft IDs that are not 1 and are also present in the airport aircraft table, excluding aircraft ID 2?

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


Question: Which driver IDs are greater than or equal to 8 but are not driver IDs less than or equal to 3?

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


Question: What are the driver IDs, excluding driver ID 8, from the driver table, and also the driver IDs, excluding driver ID 3, 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 != 3


Question: What are the document IDs and draft numbers from the Circulation History where the draft number is less than 20, combined with the document IDs and draft numbers from Document Drafts where the draft number is greater than 9?

SELECT document_id, draft_number FROM Circulation_History WHERE "draft_number" < 20 UNION SELECT document_id, draft_number FROM Document_Drafts WHERE "draft_number" > 9


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


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

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


Question: Which driver IDs, excluding ID 6, are present in both the driver and school bus tables, excluding 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: Which driver IDs are less than 11 but not found in the school bus table with driver IDs less than 3?

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


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

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


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

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


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

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


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

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


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

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


Question: What are the document IDs from the drafts where the draft details are "m" or the draft number isn't 19 and the document ID is greater than 17, along with the document IDs from the mailed documents where the address ID isn't 5 and the document ID isn't 12?

SELECT document_id FROM Document_Drafts WHERE draft_details = "m" OR "draft_number" != 19 AND "document_id" > 17 UNION ALL SELECT document_id FROM Documents_Mailed WHERE "mailed_to_address_id" != 5 AND "document_id" != 12


Question: What are the party names, party IDs, and lieutenant governors for parties that are not "Working Families" and don't have "Charles Schumer" in the US Senate, or have "Betsy McCaughey Ross" as governor, "Sandra Frankel" as lieutenant governor, and a comptroller other than "Alan Hevesi"? Also, what are the party names, party IDs, and lieutenant governors for parties with "David Paterson" as lieutenant governor, or where the year is after 2002 and the party is "Working Families", or have "Betsy McCaughey Ross" as governor?

SELECT Party, Party_ID, Lieutenant_Governor FROM party WHERE Party != "Working Families" AND US_Senate <> "Charles Schumer" OR Governor = "Betsy McCaughey Ross" AND Comptroller <> "Alan Hevesi" AND Lieutenant_Governor = "Sandra Frankel" UNION SELECT Party, Party_ID, Lieutenant_Governor FROM party WHERE Lieutenant_Governor = "David Paterson" OR "Year" > 2002.0 AND Party = "Working Families" OR Governor = "Betsy McCaughey Ross"


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

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


Question: What are the driver IDs that are either at least 3 or less than 7, 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 < 7


Question: What are the aircraft IDs that are both greater than or equal to 1 in the aircraft table and less than 2 in the airport_aircraft table?

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


Question: Which driver IDs are greater than 3, excluding driver ID 9?

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


Question: Which driver IDs are greater than or equal to 4, 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: What are the driver IDs that are greater than or equal to 6 and also less than or equal to 10, considering only drivers and school buses?

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


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


Question: What are the continent IDs and names for continents with IDs less than 2, and also for continents with IDs less than 1 and the name "asia"?

SELECT ContId, Continent FROM continents WHERE "ContId" < 2 UNION SELECT ContId, Continent FROM continents WHERE "ContId" < 1 AND Continent = "asia"


Question: Which driver IDs are not 5 from the driver table, combined with driver ID 10 from the school bus table?

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


Question: What are the average club name and start year, grouped by region, for clubs in France that started before 2001, combined with the average club name and start year, grouped by region, for clubs that started in or before 2009, or have a club ID of 5 or greater, or are not located in Korea and are not named BK Häcken?

SELECT AVG(Club_name), AVG(Start_year), Region FROM club WHERE "Start_year" < 2001 AND Region = "France" UNION SELECT AVG(Club_name), AVG(Start_year), Region FROM club WHERE "Start_year" <= 2009 OR "Club_ID" >= 5 OR Region <> "Korea" AND Club_name != "BK Häcken"


Question: What are all the template type descriptions and codes, excluding those described as "Book", and also excluding those described as "Advertisement" or with the code "AD"?

SELECT Template_Type_Description, Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Description <> "Book" UNION SELECT Template_Type_Description, Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Description <> "Advertisement" OR Template_Type_Code != "AD"


Question: What are the driver IDs, excluding driver ID 3, and also the driver IDs greater than 7, 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 > 7


Question: What are the property IDs and descriptions of features that are not "dolorem", combined with the property IDs and descriptions of features where the feature ID is 2 or the description is not "corrupti"?

SELECT property_id, property_feature_description FROM Other_Property_Features WHERE property_feature_description <> "dolorem" UNION SELECT property_id, property_feature_description FROM Other_Property_Features WHERE "feature_id" = 2 OR property_feature_description != "corrupti"


Question: What are the maximum gross weights of aircraft that either don't have a total disk area of "872 ft² (81.1 m²)", or don't have a maximum gross weight of "50,000 lb (22,680 kg)" and aren't a "Robinson R-22", or don't have a description of "Heavy-lift helicopter", or have a maximum disk loading of "2.6 lb/ft² (14 kg/m²)", or don't have an Aircraft_ID of 3, combined with the maximum gross weights of aircraft that either don't have a maximum gross weight of "1,370 lb (635 kg)" and have a maximum disk loading of "8.8 lb/ft² (43 kg/m²)", or don't have a description of "Tandem rotor helicopter", or have an Aircraft_ID greater than 5?

SELECT Max_Gross_Weight FROM aircraft WHERE Total_disk_area != "872 ft² (81.1 m²)" OR Max_Gross_Weight <> "50,000 lb (22,680 kg)" AND Aircraft != "Robinson R-22" OR Description <> "Heavy-lift helicopter" OR Max_disk_Loading = "2.6 lb/ft² (14 kg/m²)" OR "Aircraft_ID" <> 3 UNION SELECT Max_Gross_Weight FROM aircraft WHERE Max_Gross_Weight <> "1,370 lb (635 kg)" AND Max_disk_Loading = "8.8 lb/ft² (43 kg/m²)" OR Description != "Tandem rotor helicopter" OR "Aircraft_ID" > 5


Question: Which driver IDs are less than or equal to 9, and also include driver ID 10?

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


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

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


Question: What are the counts of each sex, the sum of first names, the maximum last names, city codes, ages, student IDs, and majors for students where the city code is not "ROC" or the age is greater than 18 and the student ID is less than 1012 and the sex is not "M" or the last name is not "Prater", combined with the counts of each sex, the sum of first names, the maximum last names, city codes, ages, student IDs, and majors for students where the student ID is less than 1019 and the sex is "M"?

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

SELECT COUNT(Sex), SUM(Fname), MAX(LName), city_code, Age, StuID, Major FROM Student WHERE city_code <> "ROC" OR "Age" > 18 AND "StuID" < 1012 AND Sex <> "M" OR LName != "Prater" UNION SELECT COUNT(Sex), SUM(Fname), MAX(LName), city_code, Age, StuID, Major FROM Student WHERE "StuID" < 1019 AND Sex = "M"


Question: What are the template IDs from the 'Documents' table where the document description isn't "y" and other details are "None", or where the document ID is less than or equal to 801801, or where the document name is "Data base" and the template ID isn't 8? Also, what are the template IDs from the 'Templates' table where the template details are empty, or where the effective start date is "2005-02-20 00:31:34" and the effective end date is "2008-01-05 14:19:28" and the version number isn't 7? Combine these results.

SELECT Template_ID FROM Documents WHERE Document_Description != "y" AND Other_Details = "None" OR "Document_ID" <= 801801 OR Document_Name = "Data base" AND "Template_ID" != 8 UNION ALL SELECT Template_ID FROM Templates WHERE Template_Details = "" OR Date_Effective_From = "2005-02-20 00:31:34" AND Date_Effective_To = "2008-01-05 14:19:28" AND "Version_Number" != 7


Question: What are the driver IDs that are less than 9, appearing in either the driver or school bus tables?

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


Question: Which driver IDs are less than or equal to 12, excluding those that are not equal to 4 in the school bus table?

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


Question: Which driver IDs are greater than or equal to 4 and also appear in the school bus table, excluding driver ID 10?

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


Question: What are the book IDs, prices, publishers, publication dates, and publication IDs for publications that don't have a publication ID of 7, a book ID of 3, or a publication date of April 2007, combined with those that don't have a price of 3000000.0 or a publisher of Wiley?

SELECT Book_ID, Price, Publisher, Publication_Date, Publication_ID FROM publication WHERE "Publication_ID" <> 7 OR "Book_ID" <> 3 OR Publication_Date != "April 2007" UNION SELECT Book_ID, Price, Publisher, Publication_Date, Publication_ID FROM publication WHERE "Price" != 3000000.0 AND Publisher <> "Wiley"


Question: What are the road address, city, and membership amount for branches that are not located on "Valleys Place" and have a Branch ID of 5 or greater, and also for branches that are not on "Abbott Street" or have a Branch ID of 4 or have a name that is not "Brooke Greville"?

SELECT Address_road, City, membership_amount FROM branch WHERE Address_road <> "Valleys Place" AND "Branch_ID" >= 5 INTERSECT SELECT Address_road, City, membership_amount FROM branch WHERE Address_road != "Abbott Street" OR "Branch_ID" = 4 OR Name != "Brooke Greville"


Question: What are the driver IDs that are equal to 5, but not equal to 9?

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


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

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


Question: What are the album IDs that are either less than or equal to 93 or the media type IDs that are not "AAC audio file"?

SELECT id FROM albums WHERE "id" <= 93 UNION SELECT id FROM media_types WHERE name <> "AAC audio file"


Question: What are the aircraft, their descriptions, the sum of their maximum disk loading, the minimum total disk area, and their maximum gross weight, excluding those with a maximum gross weight of 1,370 lb (635 kg) or a total disk area of 5,655 ft² (526 m²), but including those that don't have a total disk area of 8,495 ft² (789 m²) and don't meet any of these criteria: Aircraft ID greater than or equal to 4, a maximum disk loading not equal to 3.7 lb/ft² (18 kg/m²), a maximum gross weight not equal to 73,500 lb (33,300 kg), a description not equal to "Heavy-lift helicopter", or an aircraft name not equal to "Bell 206B3 JetRanger"?

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

SELECT Aircraft, Description, SUM(Max_disk_Loading), MIN(Total_disk_area), Max_Gross_Weight FROM aircraft WHERE Max_Gross_Weight <> "1,370 lb (635 kg)" AND Total_disk_area <> "5,655 ft² (526 m²)" EXCEPT SELECT Aircraft, Description, SUM(Max_disk_Loading), MIN(Total_disk_area), Max_Gross_Weight FROM aircraft WHERE Total_disk_area <> "8,495 ft² (789 m²)" AND "Aircraft_ID" >= 4 OR Max_disk_Loading != "3.7 lb/ft² (18 kg/m²)" OR Max_Gross_Weight != "73,500 lb (33,300 kg)" OR Description != "Heavy-lift helicopter" OR Aircraft <> "Bell 206B3 JetRanger"


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

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


Question: What are the driver IDs, excluding driver ID 6, from the driver table, combined with the driver IDs, excluding driver ID 10, from the school bus table?

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


Question: Which school IDs are for schools not in New York City, or in 4th grade, or not Private Catholic, or with a school ID less than or equal to 3 and not Punahou School, but are not associated with a driver ID less than or equal to 4 in the school bus table?

SELECT School_ID FROM school WHERE Location != "New York City" OR Grade = "4th grade" OR Type <> "Private Catholic" OR "School_ID" <= 3 AND School != "Punahou School" EXCEPT SELECT School_ID FROM school_bus WHERE "Driver_ID" <= 4


Question: What are the continent, the alphabetically first country name, and the country ID for countries, considering either countries that are not Australia or have a continent value less than or equal to 1, or countries with a country ID less than 3 or a country name that is not Italy?

SELECT Continent, MIN(CountryName), CountryId FROM countries WHERE CountryName != "australia" OR "Continent" <= 1 UNION SELECT Continent, MIN(CountryName), CountryId FROM countries WHERE "CountryId" < 3 OR CountryName <> "italy"


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

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


Question: What are the names and numbers of contestants whose number is 11 or greater, and also the names and numbers of contestants named "Loraine NygrenTania Mattioli" with a number greater than 6?

SELECT contestant_name, contestant_number FROM CONTESTANTS WHERE "contestant_number" >= 11 UNION SELECT contestant_name, contestant_number FROM CONTESTANTS WHERE "contestant_number" > 6 AND contestant_name = "Loraine NygrenTania Mattioli"


Question: What are the IDs of features that either have an ID of 2 or greater, or are not security features and are named "AirCon", or have a description that is not "Air Conditioning.", and also the IDs of property features that don't have the description "odio" and are not associated with property ID 15?

SELECT feature_id FROM Other_Available_Features WHERE "feature_id" >= 2 OR feature_type_code <> "Security" AND feature_name = "AirCon" OR feature_description != "Air Conditioning." UNION ALL SELECT feature_id FROM Other_Property_Features WHERE property_feature_description != "odio" AND "property_id" <> 15


Question: Which player IDs meet at least one of the following conditions: their sponsor is not "Charleswood—St. James—Assiniboia", their occupation is "Parliamentarian" and their rank is not "2nd" and they have 8734 votes, or their residence is not "Birtle", and are also associated with a coach ID of 1 or higher?

SELECT Player_ID FROM player WHERE Sponsor_name <> "Charleswood—St. James—Assiniboia" OR Occupation = "Parliamentarian" AND Rank <> "2nd" AND "Votes" = 8734 OR Residence != "Birtle" INTERSECT SELECT Player_ID FROM player_coach WHERE "Coach_ID" >= 1


Question: What are the driver IDs that are both greater than or equal to 6 and also not equal to 7, considering only those IDs present in both the driver and school bus tables?

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


Question: What are the property type codes for properties that have certain features or details, excluding those with the property type "Other" and a description that isn't "Apartment, Flat, Condo, etc."?

SELECT property_type_code FROM Properties WHERE hse_feature_2 != "None" OR fld_feature_2 != "None" OR hse_feature_3 <> "None" OR property_name = "high line" AND "buyer_offered_price" <> 3520911.5258 OR apt_feature_1 = "fuga" AND property_address = "60845 Else Highway Apt. 826 South Dougfort, CO 43200-4258" AND fld_feature_1 = "None" AND property_type_code != "House" AND oth_feature_3 = "None" AND fld_feature_3 = "None" OR shp_feature_3 <> "None" AND other_property_details <> "None" EXCEPT SELECT property_type_code FROM Ref_Property_Types WHERE property_type_code = "Other" AND property_type_description <> "Apartment, Flat, Condo, etc."


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

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 aircraft IDs that are not 2 and also appear 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 != 2 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 5


Question: What are the aircraft IDs greater than 4, combined with the aircraft IDs that are at least 1, considering both the aircraft and airport_aircraft tables?

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


Question: How many albums are there where the artist ID isn't 90 or the title isn't "A TempestadeTempestade Ou O Livro Dos Dias", excluding the number of Blues genres?

SELECT COUNT(id) FROM albums WHERE "artist_id" != 90 OR title <> "A TempestadeTempestade Ou O Livro Dos Dias" EXCEPT SELECT COUNT(id) FROM genres WHERE name = "Blues"


Question: What are the document IDs from the Documents_Mailed table where the ID is 12 or greater, the mailing date isn't "1979-09-21 10:30:52", and the address ID is greater than 3, but not found in the Draft_Copies table with an ID less than 23?

SELECT document_id FROM Documents_Mailed WHERE "document_id" >= 12 AND mailing_date <> "1979-09-21 10:30:52" AND "mailed_to_address_id" > 3 EXCEPT SELECT document_id FROM Draft_Copies WHERE "document_id" < 23


Question: What are the driver IDs that are less than 2, and also the driver IDs that are greater than 9, considering both the driver and school bus records?

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


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

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


Question: Which driver IDs are greater than 8 but not also driver IDs that are less than or equal to 4, considering only the driver IDs?

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


Question: Which driver IDs are less than 3, and which driver IDs are greater than 9, considering only 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 > 9


Question: Which driver IDs are greater than 5, excluding any driver ID that is equal to 4?

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


Question: Which driver IDs are in the driver table, excluding driver ID 11, or are in the school bus table with driver ID 3?

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: Give me the employee IDs and copy numbers for records where the document ID is 1 or the employee ID is less than 2 and the draft number is no more than 1, but exclude those records where the document ID is 2.

SELECT employee_id, copy_number FROM Circulation_History WHERE "document_id" = 1 OR "employee_id" < 2 AND "draft_number" <= 1 EXCEPT SELECT employee_id, copy_number FROM Circulation_History WHERE "document_id" = 2


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

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


Question: What are the driver IDs less than 8 from the driver table, combined with the driver IDs greater 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 ranking and maximum creation dates for departments, excluding those with ID 12, but not including any departments where the budget isn't 11.1 billion, the creation year isn't 1989, the ID isn't 8, the number of employees isn't 71436, or the name is "State"?

SELECT Ranking, MAX(Creation) FROM department WHERE "Department_ID" <> 12 EXCEPT SELECT Ranking, MAX(Creation) FROM department WHERE "Budget_in_Billions" <> 11.1 AND Creation = "1989" AND "Department_ID" != 8 AND "Num_Employees" != 71436.0 OR Name = "State"


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

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


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

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 driver IDs, excluding driver ID 1, that are present in both the driver and school bus tables, where the school bus driver ID is greater than 7?

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


Question: What are the driver IDs that are both less than or equal to 5 and also not equal to 3, 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 <= 5 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 3


Question: What are the driver IDs, excluding driver 12, that are present in both the driver and school bus tables, excluding driver 3?

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


Question: What are the years of working for school bus drivers who have worked for at least 2 years, and also for those who work at school ID 5 but are not full-time?

SELECT Years_Working FROM school_bus WHERE "Years_Working" >= 2 UNION ALL SELECT Years_Working FROM school_bus WHERE "School_ID" = 5 AND If_full_time <> "T"


Question: What are all the draft numbers from the Document_Drafts table where the draft details are not "k", and also all draft numbers from the Draft_Copies table where the document ID is at least 2 and the draft number is greater than 17, or the copy number is not 15?

SELECT draft_number FROM Document_Drafts WHERE draft_details <> "k" UNION ALL SELECT draft_number FROM Draft_Copies WHERE "document_id" >= 2 AND "draft_number" > 17 OR "copy_number" <> 15


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

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


Question: What are the driver IDs that are less than or equal to 9, and also what are the driver IDs greater than 10, considering both drivers and school buses?

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


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

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


Question: What are the IDs of people named Semen Poltavskiy or with a People_ID not equal to 3 or a height not equal to 207.0 and a birth date not equal to July 14, 1983, combined with the IDs of poker players with a Poker_Player_ID greater than or equal to 5 or a People_ID not equal to 5 or a Money_Rank less than 166.0 and a Best_Finish less than 1.0?

SELECT People_ID FROM people WHERE Name = "Semen Poltavskiy" OR "People_ID" <> 3 OR "Height" != 207.0 AND Birth_Date <> "July 14, 1983" UNION SELECT People_ID FROM poker_player WHERE "Poker_Player_ID" >= 5 OR "People_ID" != 5 OR "Money_Rank" < 166.0 AND "Best_Finish" < 1.0


Question: Which club IDs meet either of these conditions: the club started in or after 2005 or the club name is not BK Häcken, or the club has at least 10 small silver medals, or the club has less than 102 points, or the club has 9 or fewer bronze medals, or the club has a gold medal count that is not 13 and the club ID is less than 3?

SELECT Club_ID FROM club WHERE "Start_year" >= 2005 OR Club_name <> "BK Häcken" UNION ALL SELECT Club_ID FROM match_result WHERE "Small_Silver" >= 10 OR "Points" < 102 OR "Bronze" <= 9 OR "Gold" <> 13 AND "Club_ID" < 3


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

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


Question: What is the sum of Store IDs from the 'store' table where the store type is "City Mall", or the ranking is less than 10 and the area size is at least 28.74 and the store name is not "Miramichi", or the number of product categories is not 17811, or the store ID is not 4, excluding the sum of Store IDs from the 'store_product' table where the product ID is less than or equal to 1 and the store ID is less than or equal to 1?

SELECT SUM(Store_ID) FROM store WHERE Type = "City Mall" OR "Ranking" < 10 AND "Area_size" >= 28.74 AND Store_Name <> "Miramichi" OR "Number_of_product_category" != 17811.0 OR "Store_ID" != 4 EXCEPT SELECT SUM(Store_ID) FROM store_product WHERE "Product_ID" <= 1 AND "Store_ID" <= 1


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

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


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

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


Question: What are the driver IDs that are both less than or equal to 8 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 <= 8 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID < 4


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

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


Question: Which driver IDs are both less than 12 and also equal to 9, 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 < 12 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 9


Question: What are the aircraft IDs that are greater than 4 and also less than or equal to 5, 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 > 4 INTERSECT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <= 5


Question: What are the user IDs from reviews where the item ID is 7 or greater, or the rating is not 6 and the account ID is less than 4, combined with the user IDs from user accounts that are not named Nancy?

SELECT u_id FROM review WHERE "i_id" >= 7 OR "rating" != 6 AND "a_id" < 4 UNION SELECT u_id FROM useracct WHERE name != "Nancy"


Question: What is the lowest value in the 'other_details' column from the 'Documents' table where the shipping agent isn't "UP" and the receipt number isn't "61", combined with the lowest 'other_details' value from the 'Employees' table where the role is "PT" or the other details aren't "v"?

SELECT MIN(other_details) FROM Documents WHERE shipping_agent_code != "UP" AND receipt_number <> "61" UNION ALL SELECT MIN(other_details) FROM Employees WHERE role_code = "PT" OR other_details != "v"


Question: Which driver IDs are less than or equal to 3 but are not present in the school bus table with driver IDs less than 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 driver IDs that are both less than or equal to 10 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 <= 10 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 10


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

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


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

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


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

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


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

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


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

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


Question: What are the IDs of drivers who are either in the driver table or the school bus table, excluding driver ID 10?

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


Question: What are the aircraft IDs less than 5 that are not present in the airport aircraft table, excluding aircraft ID 1?

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


Question: What are the area size, number of product categories, ranking, store name, and type for all stores, excluding Rogersville, and also for stores where the area size is not 7.23, the ranking is not 10, or the number of product categories is greater than 1678?

SELECT Area_size, Number_of_product_category, Ranking, Store_Name, Type FROM store WHERE Store_Name != "Rogersville" UNION ALL SELECT Area_size, Number_of_product_category, Ranking, Store_Name, Type FROM store WHERE "Area_size" <> 7.23 AND "Ranking" <> 10 OR "Number_of_product_category" > 1678.0


Question: What are the driver IDs that are equal to 5, excluding those driver IDs that are not equal to 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: What is the smallest value in the 'other_details' column from the 'Documents' table, excluding rows where 'receipt_number' is "19", and also the smallest value in the 'other_details' column from the 'Employees' table, excluding rows where 'employee_name' is "Koby" or 'other_details' is not "f"?

SELECT MIN(other_details) FROM Documents WHERE receipt_number != "19" INTERSECT SELECT MIN(other_details) FROM Employees WHERE employee_name != "Koby" OR other_details <> "f"


Question: What is the maximum earnings and the sum of People IDs for poker players where the Poker Player ID is less than or equal to 3 or the Final Table Made value is not 26, combined with the maximum earnings and the sum of People IDs for players where Final Table Made is 26, People ID is less than or equal to 5, and Money Rank is less than or equal to 154, or the Poker Player ID is less than or equal to 2?

SELECT MAX(Earnings), SUM(People_ID) FROM poker_player WHERE "Poker_Player_ID" <= 3 OR "Final_Table_Made" <> 26.0 UNION ALL SELECT MAX(Earnings), SUM(People_ID) FROM poker_player WHERE "Final_Table_Made" = 26.0 AND "People_ID" <= 5 AND "Money_Rank" <= 154.0 OR "Poker_Player_ID" <= 2


Question: What are the driver IDs, excluding driver ID 12, from the driver table, and also the driver IDs greater than 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 less than or equal to 9 and also appear in the school bus table, excluding driver ID 10?

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


Question: What are the driver IDs that are greater than 3 and also appear 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 > 3 INTERSECT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID >= 9


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

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


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

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


Question: What are the store IDs of stores that have a store ID of 2 or higher and are not named Blackville, or have a ranking of 10 or higher, or are not a City Mall? Also, what are the store IDs from any district with a district ID greater than 11?

SELECT Store_ID FROM store WHERE "Store_ID" >= 2 AND Store_Name != "Blackville" OR "Ranking" >= 10 OR Type != "City Mall" UNION ALL SELECT Store_ID FROM store_district WHERE "District_ID" > 11


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

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


Question: What are the driver IDs that are less than 9, excluding any 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 < 9 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID != 9


Question: Which driver IDs are not equal to 3, but are not also driver IDs from school buses with IDs greater 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: Which employee IDs are associated with copy numbers of 5 or more and not document ID 20, or employee IDs greater than 8? Also, include employee IDs where other details aren't "f", employee IDs are greater than 5, or the employee name isn't "Haley" or the role code isn't "MG"?

SELECT employee_id FROM Circulation_History WHERE "copy_number" >= 5 AND "document_id" != 20 OR "employee_id" > 8 UNION ALL SELECT employee_id FROM Employees WHERE other_details != "f" AND "employee_id" > 5 OR employee_name <> "Haley" OR role_code <> "MG"


Question: What are the driver IDs that are less than 9 but not greater than 7, considering only the driver and school bus tables?

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 aircraft IDs less than 5 that are not present in the airport aircraft table, excluding aircraft ID 1?

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


Question: What is the smallest store ID that is either less than 5 in the store_district table or has a product ID of 1 or less, or is store ID 2 in the store_product table?

SELECT MIN(Store_ID) FROM store_district WHERE "Store_ID" < 5 UNION SELECT MIN(Store_ID) FROM store_product WHERE "Product_ID" <= 1 OR "Store_ID" = 2


Question: How many districts are there for each city, excluding Khanewal District, where the city is not Bahawalnagar City, the store ID is at least 1, and the city population is greater than 314617?

SELECT COUNT(T1.District_ID), T2.District_ID FROM district as T1 JOIN store_district as T2 ON T1.District_ID = T2.District_ID WHERE District_name <> "Khanewal District" GROUP BY Headquartered_City HAVING Headquartered_City <> "Bahawalnagar City" AND Store_ID >= 1 AND City_Population > 314617.0


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

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


Question: Which driver IDs are greater than or equal to 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 in the driver table, excluding driver ID 2, or are in the school bus table with a driver ID of 9 or higher?

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


Question: What are the IDs of the certificate holders with an ID greater than or equal to 355548984, combined with the IDs of flights that did not originate in Los Angeles, or departed on a different date or time than April 12, 2005 at 9:30 AM, and had a flight number other than 387, and arrived on a different date or time than April 12, 2005 at 10:03 AM, or had a distance other than 2551, or went to Boston and had an ID less than 2 and a price greater than 425.98?

SELECT aid FROM certificate WHERE "eid" >= 355548984 UNION ALL SELECT aid FROM flight WHERE origin <> "Los Angeles" OR departure_date != "04/12/2005 09:30" AND "flno" <> 387 AND arrival_date != "04/12/2005 10:03" OR "distance" <> 2551 OR destination = "Boston" AND "aid" < 2 AND "price" > 425.98


Question: What are the driver IDs that are 8 or greater, excluding those driver IDs less 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: What are the driver IDs less than 12 that are in the driver table but not in the school bus table, where the school bus driver IDs are 3 or greater?

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


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

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


Question: What are the aircraft IDs greater than 3 that are present in both the aircraft and airport-aircraft tables, excluding aircraft ID 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: Which driver IDs are present in both the driver table (excluding driver ID 7) and the school bus table (specifically 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 is the sum of School IDs from the budget table where Invested is greater than 95542, or School ID is not 2 and Year is less than or equal to 2005, or Budgeted is less than or equal to 61283, excluding the sum of School IDs from the endowment table where endowment ID is less than 11 and amount is less than or equal to 8.82, or School ID is less than or equal to 3?

SELECT SUM(School_id) FROM budget WHERE "Invested" > 95542 OR "School_id" <> 2 AND "Year" <= 2005 OR "Budgeted" <= 61283 EXCEPT SELECT SUM(School_id) FROM endowment WHERE "endowment_id" < 11 AND "amount" <= 8.82 OR "School_id" <= 3


Question: Which driver IDs are less than or equal to 10, but not equal to 7, and are 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 != 7


Question: What are the IDs of students who are allergic to nuts and have an ID less than or equal to 1005, and also satisfy at least one of the following conditions: are not female, are 17 years old, have a last name other than Prater and live outside of PIT, have a major code less than 550, have an ID less than 1024, or have an advisor other than 7712?

SELECT StuID FROM Has_Allergy WHERE Allergy = "Nuts" AND "StuID" <= 1005 INTERSECT SELECT StuID FROM Student WHERE Sex <> "F" OR "Age" = 17 OR LName <> "Prater" AND city_code != "PIT" OR "Major" < 550 OR "StuID" < 1024 OR "Advisor" <> 7712


Question: What are the driver IDs that are less than 11 and present in both the driver and school bus tables, with the driver IDs in the driver table being less than 11 and the driver IDs in the school bus table being less than 9?

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


Question: Which driver IDs are not equal to 6 and 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 <> 6 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 or equal to 4 and also not equal to 3, considering only the aircraft IDs present in both the aircraft and airport_aircraft tables?

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


Question: What is the minimum document status code for documents with an ID of 20 or higher, excluding those of type "CD", shipping agent "SH", and other details "u", or with a status of "overdue" and receipt number "69", that also have an "overdue" status in the reference table?

SELECT MIN(document_status_code) FROM Documents WHERE "document_id" >= 20 AND document_type_code != "CD" AND shipping_agent_code != "SH" AND other_details != "u" OR document_status_code = "overdue" AND receipt_number = "69" INTERSECT SELECT MIN(document_status_code) FROM Ref_Document_Status WHERE document_status_code = "overdue"


Question: How many vehicles have an ID less than or equal to 1 or are not vans, and how many vehicles have an ID less than or equal to 3 and are not trucks?

SELECT COUNT(vehicle_id) FROM Vehicles WHERE "vehicle_id" <= 1 OR vehicle_details <> "Van" UNION ALL SELECT COUNT(vehicle_id) FROM Vehicles WHERE "vehicle_id" <= 3 AND vehicle_details <> "Truck"


Question: Which driver IDs are either 9 or greater than 7?

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


Question: Which aircraft IDs are in the aircraft table but not in the airport_aircraft table, excluding aircraft ID 1 from the 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: What are the IDs of documents that are both a "Paper" document type and have a copy number of 15, an employee ID that is not 8, or a draft number that is not 20, excluding document ID 10?

SELECT document_id FROM Circulation_History WHERE "document_id" <> 10 AND "copy_number" = 15 AND "employee_id" <> 8 OR "draft_number" <> 20 INTERSECT SELECT document_id FROM Documents WHERE document_type_code = "Paper"


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

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


Question: What are the descriptions and IDs of property features where the property ID is at least 4 or the feature ID is not 4 and the description isn't "quo", combined with the descriptions and IDs of features where the property ID is at most 7, the feature ID is at least 4, and the description is "vitae"?

SELECT property_feature_description, feature_id FROM Other_Property_Features WHERE "property_id" >= 4 OR "feature_id" != 4 AND property_feature_description != "quo" UNION SELECT property_feature_description, feature_id FROM Other_Property_Features WHERE "property_id" <= 7 AND "feature_id" >= 4 AND property_feature_description = "vitae"


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


Question: What are the property type descriptions that are not "Field" and also not "Apartment, Flat, Condo, etc."?

SELECT property_type_description FROM Ref_Property_Types WHERE property_type_code != "Field" INTERSECT SELECT property_type_description FROM Ref_Property_Types WHERE property_type_description != "Apartment, Flat, Condo, etc."


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

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


Question: What are the aircraft IDs that are both less than or equal to 2 and greater than 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 feature type codes for features that are not "AirCon" and don't have the description "Swimming Pool.", combined with the feature type codes that are not "Amenity" or have the name "Amenity, eg Pool."?

SELECT feature_type_code FROM Other_Available_Features WHERE feature_name != "AirCon" AND feature_description != "Swimming Pool." UNION SELECT feature_type_code FROM Ref_Feature_Types WHERE feature_type_code <> "Amenity" OR feature_type_name = "Amenity, eg Pool."


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


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

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


Question: What are the aircraft IDs that are not 2 and are present 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 <> 2 EXCEPT SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 5


Question: What are the county IDs, names, populations, and zip codes for counties that have a county ID less than 4 and a population not equal to 90000, or a name that is not "Baltimore County", and also have a county ID less than 1 or a zip code of "D02"?

SELECT County_Id, County_name, Population, Zip_code FROM county WHERE "County_Id" < 4 AND "Population" != 90000.0 OR County_name != "Baltimore County" INTERSECT SELECT County_Id, County_name, Population, Zip_code FROM county WHERE "County_Id" < 1 OR Zip_code = "D02"


Question: Which driver IDs are either driver ID 4 or school bus driver ID 10?

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


Question: What are the driver IDs that are greater than or equal to 10 and also appear in the school bus table with IDs greater than 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: Which driver IDs, excluding driver ID 2, are in the driver table but not in the school bus table, excluding driver ID 4?

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


Question: What are the driver IDs greater than 7, excluding driver ID 9?

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


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

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


Question: What are the driver IDs less than 12 who are not also driver IDs greater than 7, considering only the drivers and school buses?

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 document status codes for documents shipped by agent "SH", and also the document status codes that are "working" but not described as "mailed late"?

SELECT document_status_code FROM Documents WHERE shipping_agent_code = "SH" UNION SELECT document_status_code FROM Ref_Document_Status WHERE document_status_description <> "mailed late" AND document_status_code = "working"


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

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


Question: Which driver IDs are less than 11 but not equal to 7, 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 < 11 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID = 7


Question: What are the document status codes that are not "mailed late" or not "working", combined with the document status codes that are not "currently working on" or are "done"?

SELECT document_status_code FROM Ref_Document_Status WHERE document_status_description != "mailed late" OR document_status_code <> "working" UNION SELECT document_status_code FROM Ref_Document_Status WHERE document_status_description <> "currently working on" OR document_status_code = "done"


Question: What are the departure dates, address IDs, and nicknames of staff members, excluding those with the nickname "bkunze", but not including those whose middle name isn't "Madelyn"?

SELECT date_left_staff, staff_address_id, nickname FROM Staff WHERE nickname != "bkunze" EXCEPT SELECT date_left_staff, staff_address_id, nickname FROM Staff WHERE middle_name <> "Madelyn"


Question: What are the driver IDs that are less than or equal to 1, and also the driver IDs that are greater than or equal to 3, considering both drivers and school buses?

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


Question: What is the average feature ID for features that are not "Burglar Alarm" or have a feature ID of 4, combined with the average feature ID for property 6?

SELECT AVG(feature_id) FROM Other_Available_Features WHERE feature_description <> "Burglar Alarm" OR "feature_id" = 4 UNION SELECT AVG(feature_id) FROM Other_Property_Features WHERE "property_id" = 6


Question: What are the driver IDs greater than 11 from the driver table, combined with the driver IDs less than 10 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 < 10


Question: What are the minimum document name and template ID, along with other details, document ID, and description, for documents where the template ID is not 22, or other details are not "None", or the document name is not "How Google people work" and the document ID is not 33930? Also, what are the minimum document name and template ID, along with other details, document ID, and description, for documents where the document ID is 2394, or the template ID is 10 and other details are "None", or the document description is not "y"? Combine these results.

SELECT MIN(Document_Name), MIN(Template_ID), Other_Details, Document_ID, Document_Description FROM Documents WHERE "Template_ID" != 22 OR Other_Details <> "None" OR Document_Name <> "How Google people work" AND "Document_ID" <> 33930 UNION ALL SELECT MIN(Document_Name), MIN(Template_ID), Other_Details, Document_ID, Document_Description FROM Documents WHERE "Document_ID" = 2394 OR "Template_ID" = 10 AND Other_Details = "None" OR Document_Description <> "y"


Question: What are the student IDs of students who belong to a club with an ID less than or equal to 1, excluding student ID 1010, and also either have a major of 600 or higher, or a first name other than David and are male, or have a student ID other than 1005?

SELECT StuID FROM Member_of_club WHERE "ClubID" <= 1 AND "StuID" != 1010 INTERSECT SELECT StuID FROM Student WHERE "Major" >= 600 OR Fname <> "David" AND Sex = "M" OR "StuID" <> 1005


Question: What are the driver IDs, excluding driver ID 9, and also the driver IDs less than 7, from the driver and school bus tables?

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


Question: What are the different role codes, considering those from employees who have other details not equal to "h" or are "PR", and also role codes from roles that are "PT" or have a description of "Manager"?

SELECT role_code FROM Employees WHERE other_details <> "h" OR role_code = "PR" UNION SELECT role_code FROM Roles WHERE role_code = "PT" OR role_description = "Manager"


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

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


Question: Give me the employee ID, age, name, and city for employees who are either ID 8 or higher, not 43 years old, or live in Bristol, but exclude those whose name isn't Louis Deacon, don't live in Wasps, and aren't employee ID 9.

SELECT Employee_ID, Age, Name, City FROM employee WHERE "Employee_ID" >= 8 OR "Age" != 43 OR City = "Bristol" EXCEPT SELECT Employee_ID, Age, Name, City FROM employee WHERE Name <> "Louis Deacon" AND City <> "Wasps" AND "Employee_ID" != 9


Question: What are the driver IDs that are either less than or equal to 8, or are not equal to 3?

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


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

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


Question: What are the template type descriptions and codes, excluding those with code "PP" or description "Presentation", and also excluding those with description "Advertisement" or code "AD"?

SELECT Template_Type_Description, Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Code <> "PP" OR Template_Type_Description <> "Presentation" INTERSECT SELECT Template_Type_Description, Template_Type_Code FROM Ref_Template_Types WHERE Template_Type_Description != "Advertisement" OR Template_Type_Code <> "AD"


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

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


Question: What are the driver IDs, excluding driver ID 5, and also the driver IDs greater than 10?

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


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


Question: Which driver IDs are less than 2 but not equal to 9, considering only those 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 are the driver IDs, excluding ID 10, from the driver table, and also the driver IDs less than 3 from the school bus table?

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


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

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


Question: Which driver IDs are less than 9 but not equal to 3, considering only those IDs present in the driver table?

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


Question: What are the aircraft IDs, excluding ID 5, that are present in both the aircraft and airport_aircraft tables, but not with ID 2 in the airport_aircraft table?

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


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

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


Question: For reviews, how many reviews are there, what is the maximum article ID, and how many item IDs are there, grouped by user ID, where the user ID is not 2 and the rating is 7 or less, or where the user ID is not 2 or the item ID is less than 7?

SELECT COUNT(rank), u_id, MAX(a_id), COUNT(i_id) FROM review WHERE "u_id" <> 2 AND "rating" <= 7 UNION SELECT COUNT(rank), u_id, MAX(a_id), COUNT(i_id) FROM review WHERE "u_id" != 2 OR "i_id" < 7


Question: What are the aircraft IDs that are less than 4 in the aircraft table, combined with the aircraft IDs that are greater than 2 in the airport_aircraft table?

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


Question: Which aircraft have ID 2 or aircraft ID 5, considering aircraft and airport information?

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


Question: What are the driver IDs that are either less than or equal to 3, or greater than or equal to 10?

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


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

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


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

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


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

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


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

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


Question: What allergies are not "Dog" or are of the "animal" type, and also have an allergy type that isn't "animal"?

SELECT Allergy FROM Allergy_Type WHERE Allergy <> "Dog" OR AllergyType = "animal" INTERSECT SELECT Allergy FROM Allergy_Type WHERE AllergyType <> "animal"


Question: What is the maximum aircraft ID and total distance for Tupolev 154 aircraft or aircraft with an ID less than or equal to 16, combined with the maximum aircraft ID and total distance for flights with a price of 220.98 or flights with an aircraft ID less than or equal to 9, not going to New York, and not arriving or departing on specific dates and times, with flight numbers greater than or equal to 13 and a distance of 7487?

SELECT MAX(aid), SUM(distance) FROM aircraft WHERE name = "Tupolev 154" OR "aid" <= 16 UNION ALL SELECT MAX(aid), SUM(distance) FROM flight WHERE "price" = 220.98 OR "aid" <= 9 AND destination != "New York" AND arrival_date != "04/12/2005 08:45" AND departure_date != "04/12/2005 07:03" AND "flno" >= 13 AND "distance" = 7487


Question: What are the aircraft IDs, excluding aircraft ID 2, from the aircraft table, combined with the aircraft IDs, excluding aircraft ID 5, from the airport_aircraft table?

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


Question: What are the IDs of drivers who are not driver 4 and also drive a school bus, excluding driver 7?

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


Question: What are the driver IDs, excluding driver ID 1, and also including driver IDs greater than or equal to 9, from the driver and school bus tables?

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: Which driver IDs are not equal to 2, but are not also driver IDs from the school bus table with IDs greater than 10?

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


Question: Which driver IDs are in the driver table but not in the school bus table, excluding driver ID 9, and where the driver ID is greater than or equal to 1?

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


Question: Which driver IDs are not equal to 1 but are not also driver IDs from school buses with IDs 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: What are the driver IDs that are either greater than or equal to 8, or equal to 3, considering driver and school bus information?

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


Question: What are the shipping agent codes from the Documents table where the receipt number isn't "80", the code is "UP", or the document type is "Paper" and the document ID isn't 4 and the receipt date isn't "1996-05-31 06:51:58"? Also, what are the shipping agent codes from the Ref_Shipping_Agents table where the code isn't "FE" or the description is "t"? Combine all these results.

SELECT shipping_agent_code FROM Documents WHERE receipt_number <> "80" OR shipping_agent_code = "UP" OR document_type_code = "Paper" AND "document_id" != 4 AND receipt_date != "1996-05-31 06:51:58" UNION ALL SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_code <> "FE" OR shipping_agent_description = "t"


Question: What are the driver IDs that are equal to 1, but not driver IDs greater than 4, considering only the drivers and school buses?

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


Question: What is the minimum item ID and the item ID from the review table, where the reviewer ID is greater than 3 and the user ID is 1 and the title is "blue hoodie", or where the rank is greater than 6?

SELECT MIN(T1.i_id), T2.i_id FROM item as T1 JOIN review as T2 ON T1.i_id = T2.i_id WHERE "a_id" > 3 AND "u_id" = 1 AND title = "blue hoodie" OR "rank" > 6


Question: What are the album IDs and titles for "Chronicle, Vol. 1" that are not also employee IDs and titles for employees who don't live in Lethbridge?

SELECT id, title FROM albums WHERE title = "Chronicle, Vol. 1" EXCEPT SELECT id, title FROM employees WHERE city <> "Lethbridge"


Question: How many food allergies are there, and how many allergies other than anchovies exist for students with IDs of 1004 or higher?

SELECT COUNT(Allergy) FROM Allergy_Type WHERE AllergyType = "food" UNION SELECT COUNT(Allergy) FROM Has_Allergy WHERE Allergy != "Anchovies" AND "StuID" >= 1004


Question: What are the aircraft IDs less than 5 that are not present in the airport aircraft table with IDs less than 3?

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


Question: What are the driver IDs, excluding driver ID 12, from the driver table, and also the driver IDs greater than 7 from the school bus table?

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


Question: What are the makers and model IDs for Renault models, or where the maker value is less than or equal to 20, combined with the makers and model IDs for Buick models where the maker value is greater than or equal to 21 and the model ID is greater than or equal to 25?

SELECT Maker, ModelId FROM model_list WHERE Model = "renault" OR "Maker" <= 20 UNION SELECT Maker, ModelId FROM model_list WHERE "Maker" >= 21 AND "ModelId" >= 25 AND Model = "buick"


Question: What are the district IDs where the city area is less than or equal to 75, or the headquarters is Kasur City, or the district ID is greater than 9, or the district name is Bahawalpur District and the city population is not 89380? Also, what are the district IDs from the store district table where the store ID is not 1? Combine both sets of district IDs.

SELECT District_ID FROM district WHERE "City_Area" <= 75.0 OR Headquartered_City = "Kasur City" OR "District_ID" > 9 OR District_name = "Bahawalpur District" AND "City_Population" <> 89380.0 UNION ALL SELECT District_ID FROM store_district WHERE "Store_ID" != 1


Question: For each club that isn't "Hopkins Student Enterprises", how many clubs have a president, and what are the student IDs, where the president's description isn't "Refurbish computers; teach kids and adults about computer basics." or the student ID is less than or equal to 1007?

SELECT SUM(T1.ClubID), T2.StuID FROM Club as T1 JOIN Member_of_club as T2 ON T1.ClubID = T2.ClubID WHERE Position = "President" AND ClubName <> "Hopkins Student Enterprises" GROUP BY ClubName HAVING ClubDesc <> "Refurbish computers; teach kids and adults about computer basics." AND Position = "President" OR StuID <= 1007


Question: Which driver IDs, excluding driver ID 7, are present in the driver table, and which driver IDs, greater than or equal to 10, are present in the school bus table?

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


Question: Which driver IDs are either 5 or not 3, considering both driver and school bus information?

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


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

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


Question: What are the driver IDs that are less than or equal to 1, excluding those 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 or equal to 8 and also not equal to 3, considering only those IDs present in both the driver and school bus tables?

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


Question: What are the IDs of drivers, excluding driver 7, and also the IDs of school bus drivers, excluding driver 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: Which driver IDs are greater than or equal to 6 in the driver table, but not present in the school bus table with driver IDs greater than 10?

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


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

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 driver IDs that are both assigned to a driver and assigned to a school bus, and are greater than or equal to 7?

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


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

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


Question: Which school IDs meet at least one of these conditions: the year is before or equal to 2006, the total budgeted percentage is less than 2.0, the budgeted amount is not 6803 and the school ID is not 1, or the invested amount is greater than 2134, or the total invested percentage is not 2.0, but are not associated with the donator "Monte Plata"?

SELECT School_id FROM budget WHERE "Year" <= 2006 OR "total_budget_percent_budgeted" < 2.0 OR "Budgeted" <> 6803 AND "School_id" <> 1 OR "Invested" > 2134 OR "total_budget_percent_invested" <> 2.0 EXCEPT SELECT School_id FROM endowment WHERE donator_name = "Monte Plata"


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 IDs less than 3 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 < 3


Question: What are the smallest document IDs from the circulation history where the document ID is less than 10 or the draft number is less than 2, excluding the smallest document IDs from the documents mailed table where the address ID is not 9 and the document ID is 12?

SELECT MIN(document_id) FROM Circulation_History WHERE "document_id" < 10 OR "draft_number" < 2 EXCEPT SELECT MIN(document_id) FROM Documents_Mailed WHERE "mailed_to_address_id" != 9 AND "document_id" = 12


Question: What are the driver IDs that are either greater than or equal to 1 in the driver table or greater than 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 driver IDs that are both less than or equal to 9 and also not equal to 9, based on the driver and school bus information?

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


Question: What are the aircraft IDs, excluding ID 3, that appear in both the aircraft and airport_aircraft tables, where the airport_aircraft IDs are less 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 are the flight IDs where the flight ID is less than 2, or the pilot is not Peterson, or the date is not November 8, 1963 and the velocity is less than 240.0 and the vehicle flight number is not M2-F1 #21 and the airport ID is not 4, or the company ID is not 9? Also, what are the IDs of operate companies where the ID is 8 or less, the company wasn't incorporated in Hong Kong, the name is Hong Kong Airport Services, the group equity shareholding is 100.0, the principal activities aren't catering services, and the type isn't a joint venture?

SELECT id FROM flight WHERE "id" < 2 OR Pilot <> "Peterson" OR Date != "November 8, 1963" AND "Velocity" < 240.0 AND Vehicle_Flight_number <> "M2-F1 #21" AND "airport_id" != 4 OR "company_id" != 9 UNION SELECT id FROM operate_company WHERE "id" <= 8 AND Incorporated_in <> "Hong Kong" AND name = "Hong Kong Airport Services" AND "Group_Equity_Shareholding" = 100.0 AND Principal_activities != "Catering services" AND Type != "Joint Venture"


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

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


Question: What are the aircraft IDs greater than 4, and also the aircraft ID 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: What are the driver IDs that are either less than or equal to 1, or not equal to 10?

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: Which driver IDs are less than or equal to 2, excluding those driver IDs greater than 4?

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


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

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


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

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


Question: What are the item and author IDs, grouped by review rank, where the author ID is not 5 or the user ID is less than or equal to 2 and the title is not "pear"?

SELECT T1.i_id, T2.a_id FROM item as T1 JOIN review as T2 ON T1.i_id == T2.i_id GROUP BY rank HAVING a_id <> 5 OR u_id <= 2 AND title <> "pear"


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


Question: What are the IDs of albums by artist 153 that are not titled "Appetite for Destruction" or have an ID other than 44, along with the IDs of playlists named "Music"?

SELECT id FROM albums WHERE "artist_id" = 153 AND title <> "Appetite for Destruction" OR "id" <> 44 UNION ALL SELECT id FROM playlists WHERE name = "Music"


Question: Which driver IDs are less than or equal to 11 but not equal to 3, considering only those 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 <= 11 EXCEPT SELECT Driver_ID FROM school_bus GROUP BY Driver_ID HAVING Driver_ID <> 3


Question: What are the aircraft IDs, excluding ID 1, that appear in both the aircraft table and the airport_aircraft table, where the airport_aircraft table's aircraft ID is greater than 2?

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


Question: Which store IDs meet these criteria: the store's ranking is 1 or less, the area size is 7.23, and the number of product categories is less than 793, or the store ID is not 1; but exclude any store IDs where the store ID is greater than 2 or the district ID is less than 15?

SELECT Store_ID FROM store WHERE "Ranking" <= 1 AND "Area_size" = 7.23 AND "Number_of_product_category" < 793.0 OR "Store_ID" <> 1 EXCEPT SELECT Store_ID FROM store_district WHERE "Store_ID" > 2 OR "District_ID" < 15


Question: What allergies are either shellfish related to food allergies or are not associated with student ID 1023?

SELECT Allergy FROM Allergy_Type WHERE AllergyType = "food" AND Allergy = "Shellfish" UNION SELECT Allergy FROM Has_Allergy WHERE "StuID" <> 1023


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

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


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


Question: What are the driver IDs that are either greater than or equal to 10 in the driver table, or equal to 7 in the school bus table?

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


Question: What is the average region and maximum start year, along with the club name and ID, for clubs in Korea that started after 1998, combined with the same information for clubs not in France?

SELECT AVG(Region), MAX(Start_year), Club_name, Club_ID FROM club WHERE Region = "Korea" AND "Start_year" > 1998 UNION SELECT AVG(Region), MAX(Start_year), Club_name, Club_ID FROM club WHERE Region <> "France"


Question: What are the feature type codes for features with ID 4 that are not "Swimming Pool," combined with the feature type codes for feature types that are not named "Amenity, eg Pool." and are not "Amenity"?

SELECT feature_type_code FROM Other_Available_Features WHERE "feature_id" = 4 AND feature_description != "Swimming Pool." UNION SELECT feature_type_code FROM Ref_Feature_Types WHERE feature_type_name <> "Amenity, eg Pool." AND feature_type_code != "Amenity"


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

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


Question: What are the aircraft IDs that are either greater than or equal to 5 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 >= 5 UNION SELECT Aircraft_ID FROM airport_aircraft GROUP BY Aircraft_ID HAVING Aircraft_ID <> 1


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

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


Question: What is the sum of customer IDs for customers with the last name "Bernhard", or email "kitty.hand@example.net", or a cell phone number not equal to "(780)719-4206x033", or an outstanding amount greater than 3900.0, excluding the sum of customer IDs from lessons where the lesson time is "9", or the lesson date is not "2018-03-07 16:12:36" and the customer ID is 11, or the lesson ID is less than or equal to 3, or the vehicle ID is less than 2, or the lesson status is not "Cancelled", or the price is not 495.0?

SELECT SUM(customer_id) FROM Customers WHERE last_name = "Bernhard" OR email_address = "kitty.hand@example.net" OR cell_mobile_phone_number != "(780)719-4206x033" OR "amount_outstanding" > 3900.0 EXCEPT SELECT SUM(customer_id) FROM Lessons WHERE lesson_time = "9" OR lesson_date <> "2018-03-07 16:12:36" AND "customer_id" = 11 OR "lesson_id" <= 3 OR "vehicle_id" < 2 OR lesson_status_code <> "Cancelled" OR "price" <> 495.0


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

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


Question: What are the driver IDs that are not equal to 9, but are not present in the school bus table with driver IDs less than or equal to 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 employee IDs awarded in years other than 2017, excluding those from shop 5 or with employee ID not equal to 5 or are full-time?

SELECT MIN(Employee_ID) FROM evaluation WHERE Year_awarded != "2017" EXCEPT SELECT MIN(Employee_ID) FROM hiring WHERE "Shop_ID" = 5 OR "Employee_ID" <> 5 OR Is_full_time = "T"


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

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


Question: What are the driver IDs that are equal to 8, but not equal to 3 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 <> 3


Question: What are the driver IDs that are assigned to drivers but not to school buses, excluding driver ID 6 and driver ID 3 respectively?

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: Which driver IDs are less than or equal to 4, or which driver IDs are greater than 7?

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


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

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


Question: How many properties have a feature ID less than 2, and how many properties have a non-"None" value for oth_feature_3 and a vendor requested price greater than 13.4715 and a non-"None" value for fld_feature_1, or a date on the market of "2016-05-06 16:53:39", or a non-"None" value for oth_feature_2 and a "None" value for fld_feature_2 and a non-"None" value for shp_feature_2?

SELECT COUNT(property_id) FROM Other_Property_Features WHERE "feature_id" < 2 UNION ALL SELECT COUNT(property_id) FROM Properties WHERE oth_feature_3 <> "None" AND "vendor_requested_price" > 13.4715 AND fld_feature_1 != "None" OR date_on_market = "2016-05-06 16:53:39" OR oth_feature_2 != "None" AND fld_feature_2 = "None" AND shp_feature_2 != "None"


Question: Which driver IDs are less than 10, and also which driver IDs are 4 or greater, considering both drivers and school buses?

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


Question: What are the driver IDs, excluding driver 12, and also the driver IDs from school buses that are 9 or less?

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 other details from documents that are not document ID 801801, or not template ID 11, or not named "Summer Show", combined with the other details from paragraphs where the paragraph ID is 7 and the document ID is not 3830, or the paragraph text is not "Japan"?

SELECT Other_Details FROM Documents WHERE "Document_ID" != 801801 OR "Template_ID" <> 11 OR Document_Name <> "Summer Show" UNION SELECT Other_Details FROM Paragraphs WHERE "Paragraph_ID" = 7 AND "Document_ID" != 3830 OR Paragraph_Text != "Japan"