db_id
stringclasses
146 values
question
stringlengths
3
224
sql
stringlengths
18
577
database_schema
stringclasses
146 values
city_record
Find the number of matches in different competitions.
SELECT count(*) , Competition FROM MATCH GROUP BY Competition
CREATE TABLE "city" ( "City_ID" int, "City" text, "Hanzi" text, "Hanyu_Pinyin" text, "Regional_Population" int, "GDP" real, PRIMARY KEY ("City_ID") ) 3 rows from city table: City_ID City Hanzi Hanyu_Pinyin Regional_Population GDP 1 Shanghai 上海 Shànghǎi 23019148 1919.57 2 Nanjing ( Jiangsu ) 南京 Nánjīng 8004680 614.55 3 Hangzhou ( Zhejiang ) 杭州 Hángzhōu 8700400 701.18 CREATE TABLE "match" ( "Match_ID" int, "Date" text, "Venue" text, "Score" text, "Result" text, "Competition" text, PRIMARY KEY ("Match_ID") ) 3 rows from match table: Match_ID Date Venue Score Result Competition 1 18 February 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 2-0 Friendly match 2 19 July 1992 Estadio Rigoberto López , Managua , Nicaragua 3-0 5-0 1994 FIFA World Cup qualification 3 23 July 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 5-1 1994 FIFA World Cup qualification CREATE TABLE "temperature" ( "City_ID" int, "Jan" real, "Feb" real, "Mar" real, "Apr" real, "Jun" real, "Jul" real, "Aug" real, "Sep" real, "Oct" real, "Nov" real, "Dec" real, PRIMARY KEY ("City_ID"), FOREIGN KEY (`City_ID`) REFERENCES `city`(`City_ID`) ) 3 rows from temperature table: City_ID Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec 1 17.8 17.8 18.3 18.9 20.0 20.6 20.6 20.6 20.0 19.4 18.3 2 26.1 26.1 26.1 26.1 27.8 27.8 28.3 28.3 28.3 27.2 26.7 3 18.9 18.3 19.4 20.0 22.2 23.3 23.9 23.3 22.8 21.7 20.0 CREATE TABLE "hosting_city" ( "Year" int, "Match_ID" int, "Host_City" text, PRIMARY KEY ("Year"), FOREIGN KEY (`Host_City`) REFERENCES `city`(`City_ID`), FOREIGN KEY (`Match_ID`) REFERENCES `match`(`Match_ID`) ) 3 rows from hosting_city table: Year Match_ID Host_City 2008 1 1 2009 2 2 2010 3 2
city_record
For each competition, count the number of matches.
SELECT count(*) , Competition FROM MATCH GROUP BY Competition
CREATE TABLE "city" ( "City_ID" int, "City" text, "Hanzi" text, "Hanyu_Pinyin" text, "Regional_Population" int, "GDP" real, PRIMARY KEY ("City_ID") ) 3 rows from city table: City_ID City Hanzi Hanyu_Pinyin Regional_Population GDP 1 Shanghai 上海 Shànghǎi 23019148 1919.57 2 Nanjing ( Jiangsu ) 南京 Nánjīng 8004680 614.55 3 Hangzhou ( Zhejiang ) 杭州 Hángzhōu 8700400 701.18 CREATE TABLE "match" ( "Match_ID" int, "Date" text, "Venue" text, "Score" text, "Result" text, "Competition" text, PRIMARY KEY ("Match_ID") ) 3 rows from match table: Match_ID Date Venue Score Result Competition 1 18 February 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 2-0 Friendly match 2 19 July 1992 Estadio Rigoberto López , Managua , Nicaragua 3-0 5-0 1994 FIFA World Cup qualification 3 23 July 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 5-1 1994 FIFA World Cup qualification CREATE TABLE "temperature" ( "City_ID" int, "Jan" real, "Feb" real, "Mar" real, "Apr" real, "Jun" real, "Jul" real, "Aug" real, "Sep" real, "Oct" real, "Nov" real, "Dec" real, PRIMARY KEY ("City_ID"), FOREIGN KEY (`City_ID`) REFERENCES `city`(`City_ID`) ) 3 rows from temperature table: City_ID Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec 1 17.8 17.8 18.3 18.9 20.0 20.6 20.6 20.6 20.0 19.4 18.3 2 26.1 26.1 26.1 26.1 27.8 27.8 28.3 28.3 28.3 27.2 26.7 3 18.9 18.3 19.4 20.0 22.2 23.3 23.9 23.3 22.8 21.7 20.0 CREATE TABLE "hosting_city" ( "Year" int, "Match_ID" int, "Host_City" text, PRIMARY KEY ("Year"), FOREIGN KEY (`Host_City`) REFERENCES `city`(`City_ID`), FOREIGN KEY (`Match_ID`) REFERENCES `match`(`Match_ID`) ) 3 rows from hosting_city table: Year Match_ID Host_City 2008 1 1 2009 2 2 2010 3 2
city_record
List venues of all matches in the order of their dates starting from the most recent one.
SELECT venue FROM MATCH ORDER BY date DESC
CREATE TABLE "city" ( "City_ID" int, "City" text, "Hanzi" text, "Hanyu_Pinyin" text, "Regional_Population" int, "GDP" real, PRIMARY KEY ("City_ID") ) 3 rows from city table: City_ID City Hanzi Hanyu_Pinyin Regional_Population GDP 1 Shanghai 上海 Shànghǎi 23019148 1919.57 2 Nanjing ( Jiangsu ) 南京 Nánjīng 8004680 614.55 3 Hangzhou ( Zhejiang ) 杭州 Hángzhōu 8700400 701.18 CREATE TABLE "match" ( "Match_ID" int, "Date" text, "Venue" text, "Score" text, "Result" text, "Competition" text, PRIMARY KEY ("Match_ID") ) 3 rows from match table: Match_ID Date Venue Score Result Competition 1 18 February 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 2-0 Friendly match 2 19 July 1992 Estadio Rigoberto López , Managua , Nicaragua 3-0 5-0 1994 FIFA World Cup qualification 3 23 July 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 5-1 1994 FIFA World Cup qualification CREATE TABLE "temperature" ( "City_ID" int, "Jan" real, "Feb" real, "Mar" real, "Apr" real, "Jun" real, "Jul" real, "Aug" real, "Sep" real, "Oct" real, "Nov" real, "Dec" real, PRIMARY KEY ("City_ID"), FOREIGN KEY (`City_ID`) REFERENCES `city`(`City_ID`) ) 3 rows from temperature table: City_ID Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec 1 17.8 17.8 18.3 18.9 20.0 20.6 20.6 20.6 20.0 19.4 18.3 2 26.1 26.1 26.1 26.1 27.8 27.8 28.3 28.3 28.3 27.2 26.7 3 18.9 18.3 19.4 20.0 22.2 23.3 23.9 23.3 22.8 21.7 20.0 CREATE TABLE "hosting_city" ( "Year" int, "Match_ID" int, "Host_City" text, PRIMARY KEY ("Year"), FOREIGN KEY (`Host_City`) REFERENCES `city`(`City_ID`), FOREIGN KEY (`Match_ID`) REFERENCES `match`(`Match_ID`) ) 3 rows from hosting_city table: Year Match_ID Host_City 2008 1 1 2009 2 2 2010 3 2
city_record
What are the venues of all the matches? Sort them in the descending order of match date.
SELECT venue FROM MATCH ORDER BY date DESC
CREATE TABLE "city" ( "City_ID" int, "City" text, "Hanzi" text, "Hanyu_Pinyin" text, "Regional_Population" int, "GDP" real, PRIMARY KEY ("City_ID") ) 3 rows from city table: City_ID City Hanzi Hanyu_Pinyin Regional_Population GDP 1 Shanghai 上海 Shànghǎi 23019148 1919.57 2 Nanjing ( Jiangsu ) 南京 Nánjīng 8004680 614.55 3 Hangzhou ( Zhejiang ) 杭州 Hángzhōu 8700400 701.18 CREATE TABLE "match" ( "Match_ID" int, "Date" text, "Venue" text, "Score" text, "Result" text, "Competition" text, PRIMARY KEY ("Match_ID") ) 3 rows from match table: Match_ID Date Venue Score Result Competition 1 18 February 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 2-0 Friendly match 2 19 July 1992 Estadio Rigoberto López , Managua , Nicaragua 3-0 5-0 1994 FIFA World Cup qualification 3 23 July 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 5-1 1994 FIFA World Cup qualification CREATE TABLE "temperature" ( "City_ID" int, "Jan" real, "Feb" real, "Mar" real, "Apr" real, "Jun" real, "Jul" real, "Aug" real, "Sep" real, "Oct" real, "Nov" real, "Dec" real, PRIMARY KEY ("City_ID"), FOREIGN KEY (`City_ID`) REFERENCES `city`(`City_ID`) ) 3 rows from temperature table: City_ID Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec 1 17.8 17.8 18.3 18.9 20.0 20.6 20.6 20.6 20.0 19.4 18.3 2 26.1 26.1 26.1 26.1 27.8 27.8 28.3 28.3 28.3 27.2 26.7 3 18.9 18.3 19.4 20.0 22.2 23.3 23.9 23.3 22.8 21.7 20.0 CREATE TABLE "hosting_city" ( "Year" int, "Match_ID" int, "Host_City" text, PRIMARY KEY ("Year"), FOREIGN KEY (`Host_City`) REFERENCES `city`(`City_ID`), FOREIGN KEY (`Match_ID`) REFERENCES `match`(`Match_ID`) ) 3 rows from hosting_city table: Year Match_ID Host_City 2008 1 1 2009 2 2 2010 3 2
city_record
what is the GDP of the city with the largest population.
SELECT gdp FROM city ORDER BY Regional_Population DESC LIMIT 1
CREATE TABLE "city" ( "City_ID" int, "City" text, "Hanzi" text, "Hanyu_Pinyin" text, "Regional_Population" int, "GDP" real, PRIMARY KEY ("City_ID") ) 3 rows from city table: City_ID City Hanzi Hanyu_Pinyin Regional_Population GDP 1 Shanghai 上海 Shànghǎi 23019148 1919.57 2 Nanjing ( Jiangsu ) 南京 Nánjīng 8004680 614.55 3 Hangzhou ( Zhejiang ) 杭州 Hángzhōu 8700400 701.18 CREATE TABLE "match" ( "Match_ID" int, "Date" text, "Venue" text, "Score" text, "Result" text, "Competition" text, PRIMARY KEY ("Match_ID") ) 3 rows from match table: Match_ID Date Venue Score Result Competition 1 18 February 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 2-0 Friendly match 2 19 July 1992 Estadio Rigoberto López , Managua , Nicaragua 3-0 5-0 1994 FIFA World Cup qualification 3 23 July 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 5-1 1994 FIFA World Cup qualification CREATE TABLE "temperature" ( "City_ID" int, "Jan" real, "Feb" real, "Mar" real, "Apr" real, "Jun" real, "Jul" real, "Aug" real, "Sep" real, "Oct" real, "Nov" real, "Dec" real, PRIMARY KEY ("City_ID"), FOREIGN KEY (`City_ID`) REFERENCES `city`(`City_ID`) ) 3 rows from temperature table: City_ID Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec 1 17.8 17.8 18.3 18.9 20.0 20.6 20.6 20.6 20.0 19.4 18.3 2 26.1 26.1 26.1 26.1 27.8 27.8 28.3 28.3 28.3 27.2 26.7 3 18.9 18.3 19.4 20.0 22.2 23.3 23.9 23.3 22.8 21.7 20.0 CREATE TABLE "hosting_city" ( "Year" int, "Match_ID" int, "Host_City" text, PRIMARY KEY ("Year"), FOREIGN KEY (`Host_City`) REFERENCES `city`(`City_ID`), FOREIGN KEY (`Match_ID`) REFERENCES `match`(`Match_ID`) ) 3 rows from hosting_city table: Year Match_ID Host_City 2008 1 1 2009 2 2 2010 3 2
city_record
Find the GDP of the city with the largest regional population.
SELECT gdp FROM city ORDER BY Regional_Population DESC LIMIT 1
CREATE TABLE "city" ( "City_ID" int, "City" text, "Hanzi" text, "Hanyu_Pinyin" text, "Regional_Population" int, "GDP" real, PRIMARY KEY ("City_ID") ) 3 rows from city table: City_ID City Hanzi Hanyu_Pinyin Regional_Population GDP 1 Shanghai 上海 Shànghǎi 23019148 1919.57 2 Nanjing ( Jiangsu ) 南京 Nánjīng 8004680 614.55 3 Hangzhou ( Zhejiang ) 杭州 Hángzhōu 8700400 701.18 CREATE TABLE "match" ( "Match_ID" int, "Date" text, "Venue" text, "Score" text, "Result" text, "Competition" text, PRIMARY KEY ("Match_ID") ) 3 rows from match table: Match_ID Date Venue Score Result Competition 1 18 February 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 2-0 Friendly match 2 19 July 1992 Estadio Rigoberto López , Managua , Nicaragua 3-0 5-0 1994 FIFA World Cup qualification 3 23 July 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 5-1 1994 FIFA World Cup qualification CREATE TABLE "temperature" ( "City_ID" int, "Jan" real, "Feb" real, "Mar" real, "Apr" real, "Jun" real, "Jul" real, "Aug" real, "Sep" real, "Oct" real, "Nov" real, "Dec" real, PRIMARY KEY ("City_ID"), FOREIGN KEY (`City_ID`) REFERENCES `city`(`City_ID`) ) 3 rows from temperature table: City_ID Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec 1 17.8 17.8 18.3 18.9 20.0 20.6 20.6 20.6 20.0 19.4 18.3 2 26.1 26.1 26.1 26.1 27.8 27.8 28.3 28.3 28.3 27.2 26.7 3 18.9 18.3 19.4 20.0 22.2 23.3 23.9 23.3 22.8 21.7 20.0 CREATE TABLE "hosting_city" ( "Year" int, "Match_ID" int, "Host_City" text, PRIMARY KEY ("Year"), FOREIGN KEY (`Host_City`) REFERENCES `city`(`City_ID`), FOREIGN KEY (`Match_ID`) REFERENCES `match`(`Match_ID`) ) 3 rows from hosting_city table: Year Match_ID Host_City 2008 1 1 2009 2 2 2010 3 2
city_record
What are the GDP and population of the city that already served as a host more than once?
SELECT t1.gdp , t1.Regional_Population FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city GROUP BY t2.Host_City HAVING count(*) > 1
CREATE TABLE "city" ( "City_ID" int, "City" text, "Hanzi" text, "Hanyu_Pinyin" text, "Regional_Population" int, "GDP" real, PRIMARY KEY ("City_ID") ) 3 rows from city table: City_ID City Hanzi Hanyu_Pinyin Regional_Population GDP 1 Shanghai 上海 Shànghǎi 23019148 1919.57 2 Nanjing ( Jiangsu ) 南京 Nánjīng 8004680 614.55 3 Hangzhou ( Zhejiang ) 杭州 Hángzhōu 8700400 701.18 CREATE TABLE "match" ( "Match_ID" int, "Date" text, "Venue" text, "Score" text, "Result" text, "Competition" text, PRIMARY KEY ("Match_ID") ) 3 rows from match table: Match_ID Date Venue Score Result Competition 1 18 February 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 2-0 Friendly match 2 19 July 1992 Estadio Rigoberto López , Managua , Nicaragua 3-0 5-0 1994 FIFA World Cup qualification 3 23 July 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 5-1 1994 FIFA World Cup qualification CREATE TABLE "temperature" ( "City_ID" int, "Jan" real, "Feb" real, "Mar" real, "Apr" real, "Jun" real, "Jul" real, "Aug" real, "Sep" real, "Oct" real, "Nov" real, "Dec" real, PRIMARY KEY ("City_ID"), FOREIGN KEY (`City_ID`) REFERENCES `city`(`City_ID`) ) 3 rows from temperature table: City_ID Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec 1 17.8 17.8 18.3 18.9 20.0 20.6 20.6 20.6 20.0 19.4 18.3 2 26.1 26.1 26.1 26.1 27.8 27.8 28.3 28.3 28.3 27.2 26.7 3 18.9 18.3 19.4 20.0 22.2 23.3 23.9 23.3 22.8 21.7 20.0 CREATE TABLE "hosting_city" ( "Year" int, "Match_ID" int, "Host_City" text, PRIMARY KEY ("Year"), FOREIGN KEY (`Host_City`) REFERENCES `city`(`City_ID`), FOREIGN KEY (`Match_ID`) REFERENCES `match`(`Match_ID`) ) 3 rows from hosting_city table: Year Match_ID Host_City 2008 1 1 2009 2 2 2010 3 2
city_record
Which cities have served as host cities more than once? Return me their GDP and population.
SELECT t1.gdp , t1.Regional_Population FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city GROUP BY t2.Host_City HAVING count(*) > 1
CREATE TABLE "city" ( "City_ID" int, "City" text, "Hanzi" text, "Hanyu_Pinyin" text, "Regional_Population" int, "GDP" real, PRIMARY KEY ("City_ID") ) 3 rows from city table: City_ID City Hanzi Hanyu_Pinyin Regional_Population GDP 1 Shanghai 上海 Shànghǎi 23019148 1919.57 2 Nanjing ( Jiangsu ) 南京 Nánjīng 8004680 614.55 3 Hangzhou ( Zhejiang ) 杭州 Hángzhōu 8700400 701.18 CREATE TABLE "match" ( "Match_ID" int, "Date" text, "Venue" text, "Score" text, "Result" text, "Competition" text, PRIMARY KEY ("Match_ID") ) 3 rows from match table: Match_ID Date Venue Score Result Competition 1 18 February 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 2-0 Friendly match 2 19 July 1992 Estadio Rigoberto López , Managua , Nicaragua 3-0 5-0 1994 FIFA World Cup qualification 3 23 July 1992 Estadio Cuscatlán , San Salvador , El Salvador 1-0 5-1 1994 FIFA World Cup qualification CREATE TABLE "temperature" ( "City_ID" int, "Jan" real, "Feb" real, "Mar" real, "Apr" real, "Jun" real, "Jul" real, "Aug" real, "Sep" real, "Oct" real, "Nov" real, "Dec" real, PRIMARY KEY ("City_ID"), FOREIGN KEY (`City_ID`) REFERENCES `city`(`City_ID`) ) 3 rows from temperature table: City_ID Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec 1 17.8 17.8 18.3 18.9 20.0 20.6 20.6 20.6 20.0 19.4 18.3 2 26.1 26.1 26.1 26.1 27.8 27.8 28.3 28.3 28.3 27.2 26.7 3 18.9 18.3 19.4 20.0 22.2 23.3 23.9 23.3 22.8 21.7 20.0 CREATE TABLE "hosting_city" ( "Year" int, "Match_ID" int, "Host_City" text, PRIMARY KEY ("Year"), FOREIGN KEY (`Host_City`) REFERENCES `city`(`City_ID`), FOREIGN KEY (`Match_ID`) REFERENCES `match`(`Match_ID`) ) 3 rows from hosting_city table: Year Match_ID Host_City 2008 1 1 2009 2 2 2010 3 2
e_government
List every individual's first name, middle name and last name in alphabetical order by last name.
SELECT individual_first_name , individual_middle_name , individual_last_name FROM individuals ORDER BY individual_last_name
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the first, middle, and last names of all individuals, ordered by last name?
SELECT individual_first_name , individual_middle_name , individual_last_name FROM individuals ORDER BY individual_last_name
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
List all the types of forms.
SELECT DISTINCT form_type_code FROM forms
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the different types of forms?
SELECT DISTINCT form_type_code FROM forms
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the name of the most popular party form.
SELECT t1.form_name FROM forms AS t1 JOIN party_forms AS t2 ON t1.form_id = t2.form_id GROUP BY t2.form_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What is the name of the party form that is most common?
SELECT t1.form_name FROM forms AS t1 JOIN party_forms AS t2 ON t1.form_id = t2.form_id GROUP BY t2.form_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the payment method and phone of the party with email "enrico09@example.com".
SELECT payment_method_code , party_phone FROM parties WHERE party_email = "enrico09@example.com"
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What is the payment method code and party phone of the party with the email 'enrico09@example.com'?
SELECT payment_method_code , party_phone FROM parties WHERE party_email = "enrico09@example.com"
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the emails of parties with the most popular party form.
SELECT t1.party_email FROM parties AS t1 JOIN party_forms AS t2 ON t1.party_id = t2.party_id WHERE t2.form_id = (SELECT form_id FROM party_forms GROUP BY form_id ORDER BY count(*) DESC LIMIT 1)
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the party emails associated with parties that used the party form that is the most common?
SELECT t1.party_email FROM parties AS t1 JOIN party_forms AS t2 ON t1.party_id = t2.party_id WHERE t2.form_id = (SELECT form_id FROM party_forms GROUP BY form_id ORDER BY count(*) DESC LIMIT 1)
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
List all the name of organizations in order of the date formed.
SELECT organization_name FROM organizations ORDER BY date_formed ASC
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the names of organizations, ordered by the date they were formed, ascending?
SELECT organization_name FROM organizations ORDER BY date_formed ASC
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the name of the youngest organization.
SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What is the name of the organization that was formed most recently?
SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the last name of the latest contact individual of the organization "Labour Party".
SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.organization_name = "Labour Party" ORDER BY t2.date_contact_to DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What is the last name of the contact individual from the Labour party organization who was contacted most recently?
SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.organization_name = "Labour Party" ORDER BY t2.date_contact_to DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the last name of the first ever contact person of the organization with the highest UK Vat number.
SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.uk_vat_number = (SELECT max(uk_vat_number) FROM organizations) ORDER BY t2.date_contact_to ASC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What is the last name of the first individual contacted from the organization with the maximum UK Vat number across all organizations?
SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.uk_vat_number = (SELECT max(uk_vat_number) FROM organizations) ORDER BY t2.date_contact_to ASC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
How many services are there?
SELECT count(*) FROM services
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Count the number of services.
SELECT count(*) FROM services
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find name of the services that has never been used.
SELECT service_name FROM services EXCEPT SELECT t1.service_name FROM services AS t1 JOIN party_services AS t2 ON t1.service_id = t2.service_id
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the names of the services that have never been used?
SELECT service_name FROM services EXCEPT SELECT t1.service_name FROM services AS t1 JOIN party_services AS t2 ON t1.service_id = t2.service_id
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the name of all the cities and states.
SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the names of all cities and states?
SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
How many cities are there in state "Colorado"?
SELECT count(*) FROM addresses WHERE state_province_county = "Colorado"
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Count the number of cities in the state of Colorado.
SELECT count(*) FROM addresses WHERE state_province_county = "Colorado"
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the payment method code used by more than 3 parties.
SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING count(*) > 3
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the payment method codes that have been used by more than 3 parties?
SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING count(*) > 3
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the name of organizations whose names contain "Party".
SELECT organization_name FROM organizations WHERE organization_name LIKE "%Party%"
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the names of organizations that contain the word "Party"?
SELECT organization_name FROM organizations WHERE organization_name LIKE "%Party%"
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
How many distinct payment methods are used by parties?
SELECT count(DISTINCT payment_method_code) FROM parties
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Count the number of different payment method codes used by parties.
SELECT count(DISTINCT payment_method_code) FROM parties
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Which is the email of the party that has used the services the most number of times?
SELECT t1.party_email FROM parties AS t1 JOIN party_services AS t2 ON t1.party_id = t2.customer_id GROUP BY t1.party_email ORDER BY count(*) DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Return the party email that has used party services the greatest number of times.
SELECT t1.party_email FROM parties AS t1 JOIN party_services AS t2 ON t1.party_id = t2.customer_id GROUP BY t1.party_email ORDER BY count(*) DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Which state can address "6862 Kaitlyn Knolls" possibly be in?
SELECT state_province_county FROM addresses WHERE line_1_number_building LIKE "%6862 Kaitlyn Knolls%"
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Give the state corresponding to the line number building "6862 Kaitlyn Knolls".
SELECT state_province_county FROM addresses WHERE line_1_number_building LIKE "%6862 Kaitlyn Knolls%"
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What is the name of organization that has the greatest number of contact individuals?
SELECT t1.organization_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id GROUP BY t1.organization_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Return the name of the organization which has the most contact individuals.
SELECT t1.organization_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id GROUP BY t1.organization_name ORDER BY count(*) DESC LIMIT 1
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
Find the last name of the individuals that have been contact individuals of an organization.
SELECT DISTINCT t1.individual_last_name FROM individuals AS t1 JOIN organization_contact_individuals AS t2 ON t1.individual_id = t2.individual_id
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
e_government
What are the last names of individuals who have been contact individuals for an organization?
SELECT DISTINCT t1.individual_last_name FROM individuals AS t1 JOIN organization_contact_individuals AS t2 ON t1.individual_id = t2.individual_id
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `line_1_number_building` VARCHAR(80), `town_city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50) ) 3 rows from Addresses table: address_id line_1_number_building town_city zip_postcode state_province_county country 1 25518 Ortiz Centers West Stacy 193 NorthCarolina USA 2 033 Stracke Parkways Lake Meaghan 227 Colorado USA 3 269 Flatley Port Suite 062 Breanneberg 527 NewHampshire USA CREATE TABLE `Services` ( `service_id` INTEGER PRIMARY KEY, `service_type_code` VARCHAR(15) NOT NULL, `service_name` VARCHAR(80), `service_descriptio` VARCHAR(255) ) 3 rows from Services table: service_id service_type_code service_name service_descriptio 1 Education Education Education 2 Welfare Health Welfare 3 Education Education Health CREATE TABLE `Forms` ( `form_id` INTEGER PRIMARY KEY, `form_type_code` VARCHAR(15) NOT NULL, `service_id` INTEGER, `form_number` VARCHAR(50), `form_name` VARCHAR(80), `form_description` VARCHAR(255), FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ) ) 3 rows from Forms table: form_id form_type_code service_id form_number form_name form_description 1 Basic 13 8069 SSN Application Form for SSN Application 2 Complex 9 2675 Marriage Certificate Marriage Certificate 3 Complex 2 9837 Divorce Certificate Divorce Certificate CREATE TABLE `Individuals` ( `individual_id` INTEGER PRIMARY KEY, `individual_first_name` VARCHAR(80), `individual_middle_name` VARCHAR(80), `inidividual_phone` VARCHAR(80), `individual_email` VARCHAR(80), `individual_address` VARCHAR(255), `individual_last_name` VARCHAR(80) ) 3 rows from Individuals table: individual_id individual_first_name individual_middle_name inidividual_phone individual_email individual_address individual_last_name 1 Oscar Hosea 1-925-696-5232 amie.okuneva@example.org 6956 Lia Plaza Maggio 2 Geovanny Antonia 075.012.6775x409 jamey.effertz@example.net 69578 Baylee Prairie Kerluke 3 Casper Mitchell 1-818-062-2837 brandon.hermiston@example.com 4555 Hane Orchard Kutch CREATE TABLE `Organizations` ( `organization_id` INTEGER PRIMARY KEY, `date_formed` DATETIME, `organization_name` VARCHAR(255), `uk_vat_number` VARCHAR(20) ) 3 rows from Organizations table: organization_id date_formed organization_name uk_vat_number 1 2016-08-24 23:52:48 Labour Party 2157 2 2016-10-01 12:42:01 Plaid Cymru 7459 3 2016-10-09 07:22:53 Conservative 1211 CREATE TABLE `Parties` ( `party_id` INTEGER PRIMARY KEY, `payment_method_code` VARCHAR(15) NOT NULL, `party_phone` VARCHAR(80), `party_email` VARCHAR(80) ) 3 rows from Parties table: party_id payment_method_code party_phone party_email 1 Cheque 05374656172 enrico09@example.com 2 Credit Card 1-525-947-7867x51521 brakus.aliya@example.com 3 Cheque 1-606-232-3728x3568 frida57@example.org CREATE TABLE `Organization_Contact_Individuals` ( `individual_id` INTEGER NOT NULL, `organization_id` INTEGER NOT NULL, `date_contact_from` DATETIME NOT NULL, `date_contact_to` DATETIME, PRIMARY KEY (`individual_id`,`organization_id` ), FOREIGN KEY (`organization_id` ) REFERENCES `Organizations`(`organization_id` ), FOREIGN KEY (`individual_id` ) REFERENCES `Individuals`(`individual_id` ) ) 3 rows from Organization_Contact_Individuals table: individual_id organization_id date_contact_from date_contact_to 13 1 2016-08-16 22:09:11 2018-03-25 10:27:18 11 1 2017-03-02 00:00:16 2018-03-06 05:39:43 10 3 2016-08-23 03:24:24 2018-03-12 07:55:28 CREATE TABLE `Party_Addresses` ( `party_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type_code` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, PRIMARY KEY (`party_id`, `address_id`), FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Addresses table: party_id address_id date_address_from address_type_code date_address_to 10 8 2016-04-08 22:40:02 Residence 2018-02-28 23:14:41 15 5 2016-05-20 23:22:06 Billing 2018-01-29 16:48:01 4 4 2016-05-14 15:13:30 Delivery 2018-02-25 19:39:16 CREATE TABLE `Party_Forms` ( `party_id` INTEGER NOT NULL, `form_id` INTEGER NOT NULL, `date_completion_started` DATETIME NOT NULL, `form_status_code` VARCHAR(15) NOT NULL, `date_fully_completed` DATETIME, PRIMARY KEY (`party_id`, `form_id`), FOREIGN KEY (`party_id` ) REFERENCES `Parties`(`party_id` ), FOREIGN KEY (`form_id` ) REFERENCES `Forms`(`form_id` ) ) 3 rows from Party_Forms table: party_id form_id date_completion_started form_status_code date_fully_completed 2 4 2017-12-17 11:29:47 Completed 2018-02-11 16:46:10 15 4 2017-12-16 15:25:48 Partially Completed 2018-02-18 16:09:04 8 5 2017-12-09 21:26:11 Partially Completed 2018-02-05 16:16:58 CREATE TABLE `Party_Services` ( `booking_id` INTEGER NOT NULL , `customer_id` INTEGER NOT NULL, `service_id` INTEGER NOT NULL, `service_datetime` DATETIME NOT NULL, `booking_made_date` DATETIME, FOREIGN KEY (`service_id` ) REFERENCES `Services`(`service_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Parties`(`party_id` ) ) 3 rows from Party_Services table: booking_id customer_id service_id service_datetime booking_made_date 1 10 12 2018-03-10 22:43:12 2018-03-23 23:56:51 2 14 11 2018-03-05 15:06:23 2018-03-25 11:08:29 3 4 7 2018-03-08 10:39:29 2018-03-24 11:09:52
school_bus
How many drivers are there?
SELECT count(*) FROM driver
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the name, home city, and age for all drivers.
SELECT name , home_city , age FROM driver
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the party and the number of drivers in each party.
SELECT party , count(*) FROM driver GROUP BY party
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the name of drivers in descending order of age.
SELECT name FROM driver ORDER BY age DESC
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show all different home cities.
SELECT DISTINCT home_city FROM driver
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the home city with the most number of drivers.
SELECT home_city FROM driver GROUP BY home_city ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the party with drivers from Hartford and drivers older than 40.
SELECT party FROM driver WHERE home_city = 'Hartford' AND age > 40
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show home city where at least two drivers older than 40 are from.
SELECT home_city FROM driver WHERE age > 40 GROUP BY home_city HAVING count(*) >= 2
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show all home cities except for those having a driver older than 40.
SELECT home_city FROM driver EXCEPT SELECT home_city FROM driver WHERE age > 40
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the names of the drivers without a school bus.
SELECT name FROM driver WHERE driver_id NOT IN (SELECT driver_id FROM school_bus)
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the types of schools that have two schools.
SELECT TYPE FROM school GROUP BY TYPE HAVING count(*) = 2
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the school name and driver name for all school buses.
SELECT T2.school , T3.name FROM school_bus AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN driver AS T3 ON T1.driver_id = T3.driver_id
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
What is the maximum, minimum and average years spent working on a school bus?
SELECT max(years_working) , min(years_working) , avg(years_working) FROM school_bus
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the school name and type for schools without a school bus.
SELECT school , TYPE FROM school WHERE school_id NOT IN (SELECT school_id FROM school_bus)
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
Show the type of school and the number of buses for each type.
SELECT T2.type , count(*) FROM school_bus AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id GROUP BY T2.type
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
How many drivers are from Hartford city or younger than 40?
SELECT count(*) FROM driver WHERE home_city = 'Hartford' OR age < 40
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
List names for drivers from Hartford city and younger than 40.
SELECT name FROM driver WHERE home_city = 'Hartford' AND age < 40
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
school_bus
find the name of driver who is driving the school bus with the longest working history.
SELECT t1.name FROM driver AS t1 JOIN school_bus AS t2 ON t1.driver_id = t2.driver_id ORDER BY years_working DESC LIMIT 1
CREATE TABLE "driver" ( "Driver_ID" int, "Name" text, "Party" text, "Home_city" text, "Age" int, PRIMARY KEY ("Driver_ID") ) 3 rows from driver table: Driver_ID Name Party Home_city Age 1 Matthew Ritter Dem Hartford 40 2 Dan Carter Rep Bethel 30 3 Minnie Gonzalez Dem Hartford 46 CREATE TABLE "school" ( "School_ID" int, "Grade" text, "School" text, "Location" text, "Type" text, PRIMARY KEY ("School_ID") ) 3 rows from school table: School_ID Grade School Location Type 1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public 2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic 3 4th grade State Elementary School Menteng 01 Jakarta, Indonesia Public CREATE TABLE "school_bus" ( "School_ID" int, "Driver_ID" int, "Years_Working" int, "If_full_time" bool, PRIMARY KEY ("School_ID","Driver_ID"), FOREIGN KEY ("School_ID") REFERENCES `school`("School_ID"), FOREIGN KEY ("Driver_ID") REFERENCES `driver`("Driver_ID") ) 3 rows from school_bus table: School_ID Driver_ID Years_Working If_full_time 1 10 10 F 5 7 8 T 3 4 6 T
flight_company
How many flights have a velocity larger than 200?
SELECT count(*) FROM flight WHERE velocity > 200
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
List the vehicle flight number, date and pilot of all the flights, ordered by altitude.
SELECT vehicle_flight_number , date , pilot FROM flight ORDER BY altitude ASC
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
List the id, country, city and name of the airports ordered alphabetically by the name.
SELECT id , country , city , name FROM airport ORDER BY name
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What is maximum group equity shareholding of the companies?
SELECT max(group_equity_shareholding) FROM operate_company
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What is the velocity of the pilot named 'Thompson'?
SELECT avg(velocity) FROM flight WHERE pilot = 'Thompson'
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What are the names and types of the companies that have ever operated a flight?
SELECT T1.name , T1.type FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What are the names of the airports which are not in the country 'Iceland'?
SELECT name FROM airport WHERE country != 'Iceland'
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What are the distinct types of the companies that have operated any flights with velocity less than 200?
SELECT DISTINCT T1.type FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T2.velocity < 200
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What are the ids and names of the companies that operated more than one flight?
SELECT T1.id , T1.name FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id GROUP BY T1.id HAVING count(*) > 1
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What is the id, name and IATA code of the airport that had most number of flights?
SELECT T1.id , T1.name , T1.IATA FROM airport AS T1 JOIN flight AS T2 ON T1.id = T2.airport_id GROUP BY T2.id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What are the different pilot names who had piloted a flight in the country 'United States' or in the airport named 'Billund Airport'?
SELECT DISTINCT T2.pilot FROM airport AS T1 JOIN flight AS T2 ON T1.id = T2.airport_id WHERE T1.country = 'United States' OR T1.name = 'Billund Airport'
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
What is the most common company type, and how many are there?
SELECT TYPE , count(*) FROM operate_company GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
How many airports haven't the pilot 'Thompson' driven an aircraft?
SELECT count(*) FROM airport WHERE id NOT IN ( SELECT airport_id FROM flight WHERE pilot = 'Thompson' );
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
List the name of the pilots who have flied for both a company that mainly provide 'Cargo' services and a company that runs 'Catering services' activities.
SELECT T2.pilot FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T1.principal_activities = 'Cargo' INTERSECT SELECT T2.pilot FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id WHERE T1.principal_activities = 'Catering services'
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
Which of the airport names contains the word 'international'?
SELECT name FROM airport WHERE name LIKE '%international%'
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
How many companies operates airlines in each airport?
SELECT T3.id , count(*) FROM operate_company AS T1 JOIN flight AS t2 ON T1.id = T2.company_id JOIN airport AS T3 ON T2.airport_id = T3.id GROUP BY T3.id
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
how many airports are there in each country?
SELECT count(*) , country FROM airport GROUP BY country
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
which countries have more than 2 airports?
SELECT country FROM airport GROUP BY country HAVING count(*) > 2
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
flight_company
which pilot is in charge of the most number of flights?
SELECT pilot FROM flight GROUP BY pilot ORDER BY count(*) DESC LIMIT 1
CREATE TABLE "airport" ( "id" int, "City" text, "Country" text, "IATA" text, "ICAO" text, "name" text, primary key("id") ) 3 rows from airport table: id City Country IATA ICAO name 1 Akureyri Iceland AEY BIAR Akureyri Airport 2 Amsterdam Netherlands AMS EHAM Schiphol Airport 3 Anchorage United States ANC PANC Ted Stevens Airport CREATE TABLE "operate_company" ( "id" int, "name" text, "Type" text, "Principal_activities" text, "Incorporated_in" text, "Group_Equity_Shareholding" real, primary key ("id") ) 3 rows from operate_company table: id name Type Principal_activities Incorporated_in Group_Equity_Shareholding 1 Air China Corporate Airline China 18.77 2 Air China Cargo Joint Venture Cargo airline China 49.00 3 Air Hong Kong Joint Venture Cargo airline Hong Kong 60.00 CREATE TABLE "flight" ( "id" int, "Vehicle_Flight_number" text, "Date" text, "Pilot" text, "Velocity" real, "Altitude" real, "airport_id" int, "company_id" int, primary key ("id"), foreign key ("airport_id") references `airport`("id"), foreign key ("company_id") references `operate_company`("id") ) 3 rows from flight table: id Vehicle_Flight_number Date Pilot Velocity Altitude airport_id company_id 1 M2-F1 #0 March 1, 1963 Thompson 135.0 0.0 1 2 2 M2-F1 #1 August 16, 1963 Thompson 240.0 3650.0 2 3 3 M2-F1 #6 September 3, 1963 Thompson 240.0 3650.0 2 4
cre_Docs_and_Epenses
How many accounts do we have?
SELECT count(*) FROM Accounts
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
Count the number of accounts.
SELECT count(*) FROM Accounts
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
Show all account ids and account details.
SELECT account_id , account_details FROM Accounts
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
What are the ids and details of all accounts?
SELECT account_id , account_details FROM Accounts
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
How many statements do we have?
SELECT count(*) FROM Statements
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
Count the number of statements.
SELECT count(*) FROM Statements
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
List all statement ids and statement details.
SELECT STATEMENT_ID , statement_details FROM Statements
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
What are the ids and details of all statements?
SELECT STATEMENT_ID , statement_details FROM Statements
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
Show statement id, statement detail, account detail for accounts.
SELECT T1.statement_id , T2.statement_details , T1.account_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id = T2.statement_id
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
What are the statement ids, statement details, and account details, for all accounts?
SELECT T1.statement_id , T2.statement_details , T1.account_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id = T2.statement_id
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
Show all statement id and the number of accounts for each statement.
SELECT STATEMENT_ID , count(*) FROM Accounts GROUP BY STATEMENT_ID
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
What are the different statement ids on accounts, and the number of accounts for each?
SELECT STATEMENT_ID , count(*) FROM Accounts GROUP BY STATEMENT_ID
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
Show the statement id and the statement detail for the statement with most number of accounts.
SELECT T1.statement_id , T2.statement_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id = T2.statement_id GROUP BY T1.statement_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
What are the statement id and statement detail for the statement that has the most corresponding accounts?
SELECT T1.statement_id , T2.statement_details FROM Accounts AS T1 JOIN Statements AS T2 ON T1.statement_id = T2.statement_id GROUP BY T1.statement_id ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84
cre_Docs_and_Epenses
Show the number of documents.
SELECT count(*) FROM Documents
CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15) NOT NULL, Document_Type_Name VARCHAR(255) 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_Name Document_Type_Description BK Book excellent CV CV excellent PT Presentation very good CREATE TABLE Ref_Budget_Codes ( Budget_Type_Code CHAR(15) NOT NULL, Budget_Type_Description VARCHAR(255) NOT NULL, PRIMARY KEY (Budget_Type_Code) ) 3 rows from Ref_Budget_Codes table: Budget_Type_Code Budget_Type_Description GV Government ORG Organisation SF Self founded CREATE TABLE Projects ( Project_ID INTEGER NOT NULL, Project_Details VARCHAR(255), PRIMARY KEY (Project_ID) ) 3 rows from Projects table: Project_ID Project_Details 30 Society Research project 35 Internet of Things project 105 Graph Database project CREATE TABLE Documents ( Document_ID INTEGER NOT NULL, Document_Type_Code CHAR(15) NOT NULL, Project_ID INTEGER NOT NULL, Document_Date DATETIME, Document_Name VARCHAR(255), Document_Description VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Document_Type_Code) REFERENCES Ref_Document_Types (Document_Type_Code), FOREIGN KEY (Project_ID) REFERENCES Projects (Project_ID) ) 3 rows from Documents table: Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details 29 CV 30 2004-08-28 06:59:19 Review on UK files None None 42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None 57 CV 195 1980-10-22 14:17:11 Review on French files None None CREATE TABLE Statements ( Statement_ID INTEGER NOT NULL, Statement_Details VARCHAR(255), PRIMARY KEY (Statement_ID), FOREIGN KEY (Statement_ID) REFERENCES Documents (Document_ID) ) 3 rows from Statements table: Statement_ID Statement_Details 57 Open Project 192 Private Project CREATE TABLE Documents_with_Expenses ( Document_ID INTEGER NOT NULL, Budget_Type_Code CHAR(15) NOT NULL, Document_Details VARCHAR(255), PRIMARY KEY (Document_ID), FOREIGN KEY (Budget_Type_Code) REFERENCES Ref_Budget_Codes (Budget_Type_Code), FOREIGN KEY (Document_ID) REFERENCES Documents (Document_ID) ) 3 rows from Documents_with_Expenses table: Document_ID Budget_Type_Code Document_Details 57 GV government 192 GV government 226 GV government CREATE TABLE Accounts ( Account_ID INTEGER NOT NULL, Statement_ID INTEGER NOT NULL, Account_Details VARCHAR(255), PRIMARY KEY (Account_ID), FOREIGN KEY (Statement_ID) REFERENCES Statements (Statement_ID) ) 3 rows from Accounts table: Account_ID Statement_ID Account_Details 7 57 495.063 61 57 930.14 98 57 6035.84