db_id
stringclasses
146 values
question
stringlengths
3
224
sql
stringlengths
18
577
database_schema
stringclasses
146 values
gas_company
What are the names and headquarters of all companies ordered by descending market value?
SELECT company , headquarters FROM company ORDER BY market_value DESC
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show minimum, maximum, and average market value for all companies.
SELECT min(market_value) , max(market_value) , avg(market_value) FROM company
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What is the minimum, maximum, and average market value for every company?
SELECT min(market_value) , max(market_value) , avg(market_value) FROM company
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show all main industry for all companies.
SELECT DISTINCT main_industry FROM company
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the different main industries for all companies?
SELECT DISTINCT main_industry FROM company
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
List all headquarters and the number of companies in each headquarter.
SELECT headquarters , count(*) FROM company GROUP BY headquarters
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
For each headquarter, what are the headquarter and how many companies are centered there?
SELECT headquarters , count(*) FROM company GROUP BY headquarters
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show all main industry and total market value in each industry.
SELECT main_industry , sum(market_value) FROM company GROUP BY main_industry
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the main indstries and total market value for each industry?
SELECT main_industry , sum(market_value) FROM company GROUP BY main_industry
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
List the main industry with highest total market value and its number of companies.
SELECT main_industry , count(*) FROM company GROUP BY main_industry ORDER BY sum(market_value) DESC LIMIT 1
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
For each main industry, what is the total number of companies for the industry with the highest total market value?
SELECT main_industry , count(*) FROM company GROUP BY main_industry ORDER BY sum(market_value) DESC LIMIT 1
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show headquarters with at least two companies in the banking industry.
SELECT headquarters FROM company WHERE main_industry = 'Banking' GROUP BY headquarters HAVING count(*) >= 2
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the headquarters with at least two companies in the banking industry?
SELECT headquarters FROM company WHERE main_industry = 'Banking' GROUP BY headquarters HAVING count(*) >= 2
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show gas station id, location, and manager_name for all gas stations ordered by open year.
SELECT station_id , LOCATION , manager_name FROM gas_station ORDER BY open_year
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the gas station ids, locations, and manager names for the gas stations ordered by opening year?
SELECT station_id , LOCATION , manager_name FROM gas_station ORDER BY open_year
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
How many gas station are opened between 2000 and 2005?
SELECT count(*) FROM gas_station WHERE open_year BETWEEN 2000 AND 2005
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What is the total number of gas stations that opened between 2000 and 2005?
SELECT count(*) FROM gas_station WHERE open_year BETWEEN 2000 AND 2005
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show all locations and the number of gas stations in each location ordered by the count.
SELECT LOCATION , count(*) FROM gas_station GROUP BY LOCATION ORDER BY count(*)
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
For each location, how many gas stations are there in order?
SELECT LOCATION , count(*) FROM gas_station GROUP BY LOCATION ORDER BY count(*)
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show all headquarters with both a company in banking industry and a company in Oil and gas.
SELECT headquarters FROM company WHERE main_industry = 'Banking' INTERSECT SELECT headquarters FROM company WHERE main_industry = 'Oil and gas'
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the headquarters that have both a company in the banking and 'oil and gas' industries?
SELECT headquarters FROM company WHERE main_industry = 'Banking' INTERSECT SELECT headquarters FROM company WHERE main_industry = 'Oil and gas'
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show all headquarters without a company in banking industry.
SELECT headquarters FROM company EXCEPT SELECT headquarters FROM company WHERE main_industry = 'Banking'
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the headquarters without companies that are in the banking industry?
SELECT headquarters FROM company EXCEPT SELECT headquarters FROM company WHERE main_industry = 'Banking'
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show the company name with the number of gas station.
SELECT T2.company , count(*) FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
For each company id, what are the companies and how many gas stations does each one operate?
SELECT T2.company , count(*) FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show company name and main industry without a gas station.
SELECT company , main_industry FROM company WHERE company_id NOT IN (SELECT company_id FROM station_company)
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the main industries of the companies without gas stations and what are the companies?
SELECT company , main_industry FROM company WHERE company_id NOT IN (SELECT company_id FROM station_company)
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show the manager name for gas stations belonging to the ExxonMobil company.
SELECT T3.manager_name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.company = 'ExxonMobil'
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the names of the managers for gas stations that are operated by the ExxonMobil company?
SELECT T3.manager_name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.company = 'ExxonMobil'
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show all locations where a gas station for company with market value greater than 100 is located.
SELECT T3.location FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.market_value > 100
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the locations that have gas stations owned by a company with a market value greater than 100?
SELECT T3.location FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.market_value > 100
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
Show the manager name with most number of gas stations opened after 2000.
SELECT manager_name FROM gas_station WHERE open_year > 2000 GROUP BY manager_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What is the name of the manager with the most gas stations that opened after 2000?
SELECT manager_name FROM gas_station WHERE open_year > 2000 GROUP BY manager_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
order all gas station locations by the opening year.
SELECT LOCATION FROM gas_station ORDER BY open_year
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the locations of all the gas stations ordered by opening year?
SELECT LOCATION FROM gas_station ORDER BY open_year
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
find the rank, company names, market values of the companies in the banking industry order by their sales and profits in billion.
SELECT rank , company , market_value FROM company WHERE main_industry = 'Banking' ORDER BY sales_billion , profits_billion
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What is the rank, company, and market value of every comapny in the banking industry ordered by sales and profits?
SELECT rank , company , market_value FROM company WHERE main_industry = 'Banking' ORDER BY sales_billion , profits_billion
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
find the location and Representative name of the gas stations owned by the companies with top 3 Asset amounts.
SELECT T3.location , T3.Representative_Name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id ORDER BY T2.Assets_billion DESC LIMIT 3
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
gas_company
What are the locations and representatives' names of the gas stations owned by the companies with the 3 largest amounts of assets?
SELECT T3.location , T3.Representative_Name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id ORDER BY T2.Assets_billion DESC LIMIT 3
CREATE TABLE "company" ( "Company_ID" int, "Rank" int, "Company" text, "Headquarters" text, "Main_Industry" text, "Sales_billion" real, "Profits_billion" real, "Assets_billion" real, "Market_Value" real, PRIMARY KEY ("Company_ID") ) 3 rows from company table: Company_ID Rank Company Headquarters Main_Industry Sales_billion Profits_billion Assets_billion Market_Value 1 1 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4 2 3 General Electric USA Conglomerate 147.3 14.2 717.2 213.7 3 4 Royal Dutch Shell Netherlands Oil and gas 470.2 30.9 340.5 227.6 CREATE TABLE "gas_station" ( "Station_ID" int, "Open_Year" int, "Location" text, "Manager_Name" text, "Vice_Manager_Name" text, "Representative_Name" text, PRIMARY KEY ("Station_ID") ) 3 rows from gas_station table: Station_ID Open_Year Location Manager_Name Vice_Manager_Name Representative_Name 1 1998 Herne Hill BrianWingrave Russell Denman Clive Burr 2 1999 Channel Hill SimonMarloe Russell Brown Rob Jefferies 3 2000 Reading North Simon Cope Derek Marloe James Colin Dave Edwards Roger CREATE TABLE "station_company" ( "Station_ID" int, "Company_ID" int, "Rank_of_the_Year" int, PRIMARY KEY ("Station_ID","Company_ID"), FOREIGN KEY (`Station_ID`) REFERENCES `gas_station`(`Station_ID`), FOREIGN KEY (`Company_ID`) REFERENCES `company`(`Company_ID`) ) 3 rows from station_company table: Station_ID Company_ID Rank_of_the_Year 11 1 1 1 3 2 6 6 3
party_people
How many regions do we have?
SELECT count(*) FROM region
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Count the number of regions.
SELECT count(*) FROM region
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show all distinct region names ordered by their labels.
SELECT DISTINCT region_name FROM region ORDER BY Label
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
What are the different region names, ordered by labels?
SELECT DISTINCT region_name FROM region ORDER BY Label
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
How many parties do we have?
SELECT count(DISTINCT party_name) FROM party
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Count the number of different parties.
SELECT count(DISTINCT party_name) FROM party
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show the ministers and the time they took and left office, listed by the time they left office.
SELECT minister , took_office , left_office FROM party ORDER BY left_office
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Who are the ministers, when did they take office, and when did they leave office, ordered by when they left office?
SELECT minister , took_office , left_office FROM party ORDER BY left_office
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show the minister who took office after 1961 or before 1959.
SELECT minister FROM party WHERE took_office > 1961 OR took_office < 1959
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Who are the ministers who took office after 1961 or before 1959?
SELECT minister FROM party WHERE took_office > 1961 OR took_office < 1959
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show all ministers who do not belong to Progress Party.
SELECT minister FROM party WHERE party_name != 'Progress Party'
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Which ministers are not a part of the Progress Party?
SELECT minister FROM party WHERE party_name != 'Progress Party'
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show all ministers and parties they belong to in descending order of the time they took office.
SELECT minister , party_name FROM party ORDER BY took_office DESC
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Who are the ministers and what parties do they belong to, listed descending by the times they took office?
SELECT minister , party_name FROM party ORDER BY took_office DESC
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Return the minister who left office at the latest time.
SELECT minister FROM party ORDER BY left_office DESC LIMIT 1
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Which minister left office the latest?
SELECT minister FROM party ORDER BY left_office DESC LIMIT 1
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
List member names and their party names.
SELECT T1.member_name , T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
What are the names of members and their corresponding parties?
SELECT T1.member_name , T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show all party names and the number of members in each party.
SELECT T2.party_name , count(*) FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
How many members are in each party?
SELECT T2.party_name , count(*) FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
What is the name of party with most number of members?
SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Return the name of the party with the most members.
SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show all party names and their region names.
SELECT T1.party_name , T2.region_name FROM party AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
What are the names of parties and their respective regions?
SELECT T1.party_name , T2.region_name FROM party AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show names of parties that does not have any members.
SELECT party_name FROM party WHERE party_id NOT IN (SELECT party_id FROM Member)
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
What are the names of parties that have no members?
SELECT party_name FROM party WHERE party_id NOT IN (SELECT party_id FROM Member)
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show the member names which are in both the party with id 3 and the party with id 1.
SELECT member_name FROM member WHERE party_id = 3 INTERSECT SELECT member_name FROM member WHERE party_id = 1
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Which member names are shared among members in the party with the id 3 and the party with the id 1?
SELECT member_name FROM member WHERE party_id = 3 INTERSECT SELECT member_name FROM member WHERE party_id = 1
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show member names that are not in the Progress Party.
SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id WHERE T2.Party_name != "Progress Party"
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Which member names corresponding to members who are not in the Progress Party?
SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id WHERE T2.Party_name != "Progress Party"
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
How many party events do we have?
SELECT count(*) FROM party_events
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Count the number of party events.
SELECT count(*) FROM party_events
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show party names and the number of events for each party.
SELECT T2.party_name , count(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
How many events are there for each party?
SELECT T2.party_name , count(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Show all member names who are not in charge of any event.
SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
What are the names of members who are not in charge of any events?
SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
What are the names of parties with at least 2 events?
SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id HAVING count(*) >= 2
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Return the names of parties that have two or more events.
SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id HAVING count(*) >= 2
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
What is the name of member in charge of greatest number of events?
SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Return the name of the member who is in charge of the most events.
SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
find the event names that have more than 2 records.
SELECT event_name FROM party_events GROUP BY event_name HAVING count(*) > 2
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Which event names were used more than twice for party events?
SELECT event_name FROM party_events GROUP BY event_name HAVING count(*) > 2
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
How many Annual Meeting events happened in the United Kingdom region?
SELECT count(*) FROM region AS t1 JOIN party AS t2 ON t1.region_id = t2.region_id JOIN party_events AS t3 ON t2.party_id = t3.party_id WHERE t1.region_name = "United Kingdom" AND t3.Event_Name = "Annaual Meeting"
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
party_people
Count the number of Annual Meeting events that took place in the region of the United Kingdom.
SELECT count(*) FROM region AS t1 JOIN party AS t2 ON t1.region_id = t2.region_id JOIN party_events AS t3 ON t2.party_id = t3.party_id WHERE t1.region_name = "United Kingdom" AND t3.Event_Name = "Annaual Meeting"
CREATE TABLE "region" ( "Region_ID" int, "Region_name" text, "Date" text, "Label" text, "Format" text, "Catalogue" text, PRIMARY KEY ("Region_ID") ) 3 rows from region table: Region_ID Region_name Date Label Format Catalogue 1 United Kingdom 1 July 2002 Parlophone CD 540 3622 2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821 3 Japan 3 July 2002 Toshiba-EMI CD TOCP-66045 CREATE TABLE "party" ( "Party_ID" int, "Minister" text, "Took_office" text, "Left_office" text, "Region_ID" int, "Party_name" text, PRIMARY KEY ("Party_ID"), FOREIGN KEY (`Region_ID`) REFERENCES `region`(`Region_ID`) ) 3 rows from party table: Party_ID Minister Took_office Left_office Region_ID Party_name 1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party 2 Kojo Botsio (MP) 1958 1959 2 Progress Party 3 Ebenezer Ako-Adjei (MP) 1959 1960 3 3 CREATE TABLE "member" ( "Member_ID" int, "Member_Name" text, "Party_ID" text, "In_office" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`) ) 3 rows from member table: Member_ID Member_Name Party_ID In_office 1 Hon Tony Abbott 3 1994–present 2 Hon Dick Adams 2 1993–2013 3 Anthony Albanese 2 1996–present CREATE TABLE "party_events" ( "Event_ID" int, "Event_Name" text, "Party_ID" int, "Member_in_charge_ID" int, PRIMARY KEY ("Event_ID"), FOREIGN KEY (`Party_ID`) REFERENCES `party`(`Party_ID`), FOREIGN KEY (`Member_in_charge_ID`) REFERENCES `member`(`Member_ID`) ) 3 rows from party_events table: Event_ID Event_Name Party_ID Member_in_charge_ID 1 Annaual Meeting 1 4 2 Conference 1 12 3 Annaual Meeting 2 2
pilot_record
How many pilots are there?
SELECT count(*) FROM pilot
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
List the names of pilots in ascending order of rank.
SELECT Pilot_name FROM pilot ORDER BY Rank ASC
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
What are the positions and teams of pilots?
SELECT POSITION , Team FROM pilot
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
List the distinct positions of pilots older than 30.
SELECT DISTINCT POSITION FROM pilot WHERE Age > 30
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
Show the names of pilots from team "Bradley" or "Fordham".
SELECT Pilot_name FROM pilot WHERE Team = "Bradley" OR Team = "Fordham"
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
What is the joined year of the pilot of the highest rank?
SELECT Join_Year FROM pilot ORDER BY Rank ASC LIMIT 1
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
What are the different nationalities of pilots? Show each nationality and the number of pilots of each nationality.
SELECT Nationality , COUNT(*) FROM pilot GROUP BY Nationality
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
Show the most common nationality of pilots.
SELECT Nationality FROM pilot GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
Show the pilot positions that have both pilots joining after year 2005 and pilots joining before 2000.
SELECT POSITION FROM pilot WHERE Join_Year < 2000 INTERSECT SELECT POSITION FROM pilot WHERE Join_Year > 2005
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
Show the names of pilots and models of aircrafts they have flied with.
SELECT T3.Pilot_name , T2.Model FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
Show the names of pilots and fleet series of the aircrafts they have flied with in ascending order of the rank of the pilot.
SELECT T3.Pilot_name , T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID ORDER BY T3.Rank
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
Show the fleet series of the aircrafts flied by pilots younger than 34
SELECT T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID WHERE T3.Age < 34
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
Show the names of pilots and the number of records they have.
SELECT T2.Pilot_name , COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID = T2.pilot_ID GROUP BY T2.Pilot_name
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
Show names of pilots that have more than one record.
SELECT T2.Pilot_name , COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID = T2.pilot_ID GROUP BY T2.Pilot_name HAVING COUNT(*) > 1
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
pilot_record
List the names of pilots that do not have any record.
SELECT Pilot_name FROM pilot WHERE Pilot_ID NOT IN (SELECT Pilot_ID FROM pilot_record)
CREATE TABLE "aircraft" ( "Aircraft_ID" int, "Order_Year" int, "Manufacturer" text, "Model" text, "Fleet_Series" text, "Powertrain" text, "Fuel_Propulsion" text, PRIMARY KEY ("Aircraft_ID") ) 3 rows from aircraft table: Aircraft_ID Order_Year Manufacturer Model Fleet_Series Powertrain Fuel_Propulsion 1 1992 Gillig Phantom (High Floor) 444-464 (21) DD S50EGR Allison WB-400R Diesel 2 1996 Gillig Phantom (High Floor) 465-467 (3) DD S50 Allison WB-400R Diesel 3 1998 Gillig Phantom (High Floor) 468-473 (6) DD S50 Allison WB-400R Diesel CREATE TABLE "pilot" ( "Pilot_ID" int, "Pilot_name" text, "Rank" int, "Age" int, "Nationality" text, "Position" text, "Join_Year" int, "Team" text, PRIMARY KEY ("Pilot_ID") ) 3 rows from pilot table: Pilot_ID Pilot_name Rank Age Nationality Position Join_Year Team 1 Patrick O'Bryant 13 33 United States Center Team 2009 Bradley 2 Jermaine O'Neal 6 40 United States Forward-Center Team 2008 Eau Claire High School 3 Dan O'Sullivan 45 37 United States Center Team 1999 Fordham CREATE TABLE "pilot_record" ( "Record_ID" int, "Pilot_ID" int, "Aircraft_ID" int, "Date" text, PRIMARY KEY ("Pilot_ID", "Aircraft_ID", "Date"), FOREIGN KEY (`Pilot_ID`) REFERENCES `pilot`(`Pilot_ID`), FOREIGN KEY (`Aircraft_ID`) REFERENCES `aircraft`(`Aircraft_ID`) ) 3 rows from pilot_record table: Record_ID Pilot_ID Aircraft_ID Date 1 1 1 2003/01/04 2 2 1 2004/01/04 3 1 4 2005/01/04
cre_Doc_Control_Systems
What document status codes do we have?
SELECT document_status_code FROM Ref_Document_Status;
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ) 3 rows from Ref_Document_Types table: document_type_code document_type_description CD b Paper u Hard Drive f CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ) 3 rows from Roles table: role_code role_description ED Editor PT Photo MG Manager CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ) 3 rows from Addresses table: address_id address_details 0 IT 1 MX 2 DE CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ) 3 rows from Ref_Document_Status table: document_status_code document_status_description working currently working on done mailed overdue mailed late CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ) 3 rows from Ref_Shipping_Agents table: shipping_agent_code shipping_agent_name shipping_agent_description UP UPS g US USPS q AL Airline w CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ) 3 rows from Documents table: document_id document_status_code document_type_code shipping_agent_code receipt_date receipt_number other_details 1 working CD UP 2008-04-21 20:42:25 19 z 2 done Paper US 1974-05-08 00:00:46 34 h 3 done Paper UP 2014-12-25 17:22:44 93 h CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ) 3 rows from Employees table: employee_id role_code employee_name other_details 1 ED Koby h 2 ED Kenyon f 3 PR Haley b CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ) 3 rows from Document_Drafts table: document_id draft_number draft_details 1 0 e 1 2 k 2 1 v CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ) 3 rows from Draft_Copies table: document_id draft_number copy_number 2 8 5 4 9 6 23 9 15 CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ) 3 rows from Circulation_History table: document_id draft_number copy_number employee_id 20 17 15 8 1 2 5 1 2 1 4 2 CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ) 3 rows from Documents_Mailed table: document_id mailed_to_address_id mailing_date 2 8 1977-04-01 17:03:50 4 3 1992-11-07 15:03:41 4 9 1973-02-21 10:17:01
cre_Doc_Control_Systems
What is the description of document status code 'working'?
SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "working";
CREATE TABLE Ref_Document_Types ( document_type_code CHAR(15) NOT NULL, document_type_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_type_code) ) 3 rows from Ref_Document_Types table: document_type_code document_type_description CD b Paper u Hard Drive f CREATE TABLE Roles ( role_code CHAR(15) NOT NULL, role_description VARCHAR(255), PRIMARY KEY (role_code) ) 3 rows from Roles table: role_code role_description ED Editor PT Photo MG Manager CREATE TABLE Addresses ( address_id INTEGER NOT NULL, address_details VARCHAR(255), PRIMARY KEY (address_id) ) 3 rows from Addresses table: address_id address_details 0 IT 1 MX 2 DE CREATE TABLE Ref_Document_Status ( document_status_code CHAR(15) NOT NULL, document_status_description VARCHAR(255) NOT NULL, PRIMARY KEY (document_status_code) ) 3 rows from Ref_Document_Status table: document_status_code document_status_description working currently working on done mailed overdue mailed late CREATE TABLE Ref_Shipping_Agents ( shipping_agent_code CHAR(15) NOT NULL, shipping_agent_name VARCHAR(255) NOT NULL, shipping_agent_description VARCHAR(255) NOT NULL, PRIMARY KEY (shipping_agent_code) ) 3 rows from Ref_Shipping_Agents table: shipping_agent_code shipping_agent_name shipping_agent_description UP UPS g US USPS q AL Airline w CREATE TABLE Documents ( document_id INTEGER NOT NULL, document_status_code CHAR(15) NOT NULL, document_type_code CHAR(15) NOT NULL, shipping_agent_code CHAR(15), receipt_date DATETIME, receipt_number VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (document_id), FOREIGN KEY (document_type_code) REFERENCES Ref_Document_Types (document_type_code), FOREIGN KEY (document_status_code) REFERENCES Ref_Document_Status (document_status_code), FOREIGN KEY (shipping_agent_code) REFERENCES Ref_Shipping_Agents (shipping_agent_code) ) 3 rows from Documents table: document_id document_status_code document_type_code shipping_agent_code receipt_date receipt_number other_details 1 working CD UP 2008-04-21 20:42:25 19 z 2 done Paper US 1974-05-08 00:00:46 34 h 3 done Paper UP 2014-12-25 17:22:44 93 h CREATE TABLE Employees ( employee_id INTEGER NOT NULL, role_code CHAR(15) NOT NULL, employee_name VARCHAR(255), other_details VARCHAR(255), PRIMARY KEY (employee_id), FOREIGN KEY (role_code) REFERENCES Roles (role_code) ) 3 rows from Employees table: employee_id role_code employee_name other_details 1 ED Koby h 2 ED Kenyon f 3 PR Haley b CREATE TABLE Document_Drafts ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, draft_details VARCHAR(255), PRIMARY KEY (document_id, draft_number), FOREIGN KEY (document_id) REFERENCES Documents (document_id) ) 3 rows from Document_Drafts table: document_id draft_number draft_details 1 0 e 1 2 k 2 1 v CREATE TABLE Draft_Copies ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number), FOREIGN KEY (document_id, draft_number) REFERENCES Document_Drafts (document_id,draft_number) ) 3 rows from Draft_Copies table: document_id draft_number copy_number 2 8 5 4 9 6 23 9 15 CREATE TABLE Circulation_History ( document_id INTEGER NOT NULL, draft_number INTEGER NOT NULL, copy_number INTEGER NOT NULL, employee_id INTEGER NOT NULL, PRIMARY KEY (document_id, draft_number, copy_number, employee_id), FOREIGN KEY (document_id, draft_number, copy_number) REFERENCES Draft_Copies (document_id,draft_number,copy_number), FOREIGN KEY (employee_id) REFERENCES Employees (employee_id) ) 3 rows from Circulation_History table: document_id draft_number copy_number employee_id 20 17 15 8 1 2 5 1 2 1 4 2 CREATE TABLE Documents_Mailed ( document_id INTEGER NOT NULL, mailed_to_address_id INTEGER NOT NULL, mailing_date DATETIME, PRIMARY KEY (document_id, mailed_to_address_id), FOREIGN KEY (document_id) REFERENCES Documents (document_id), FOREIGN KEY (mailed_to_address_id) REFERENCES Addresses (address_id) ) 3 rows from Documents_Mailed table: document_id mailed_to_address_id mailing_date 2 8 1977-04-01 17:03:50 4 3 1992-11-07 15:03:41 4 9 1973-02-21 10:17:01