Schema:
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)
);
CREATE TABLE `Services` (
`service_id` INTEGER PRIMARY KEY,
`service_type_code` VARCHAR(15) NOT NULL,
`service_name` VARCHAR(80),
`service_descriptio` VARCHAR(255)
);
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` )
);
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)
);
CREATE TABLE `Organizations` (
`organization_id` INTEGER PRIMARY KEY,
`date_formed` DATETIME,
`organization_name` VARCHAR(255),
`uk_vat_number` VARCHAR(20)
);
CREATE TABLE `Parties` (
`party_id` INTEGER PRIMARY KEY,
`payment_method_code` VARCHAR(15) NOT NULL,
`party_phone` VARCHAR(80),
`party_email` VARCHAR(80)
);
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` )
);
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` )
);
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` )
);
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` )
);

Question: List every individual's first name, middle name and last name in alphabetical order by last name.
SQL:
SELECT individual_first_name ,  individual_middle_name ,  individual_last_name FROM individuals ORDER BY individual_last_name

Question: What are the first, middle, and last names of all individuals, ordered by last name?
SQL:
SELECT individual_first_name ,  individual_middle_name ,  individual_last_name FROM individuals ORDER BY individual_last_name

Question: List all the types of forms.
SQL:
SELECT DISTINCT form_type_code FROM forms

Question: What are the different types of forms?
SQL:
SELECT DISTINCT form_type_code FROM forms

Question: Find the name of the most popular party form.
SQL:
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

Question: What is the name of the party form that is most common?
SQL:
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

Question: Find the payment method and phone of the party with email "enrico09@example.com".
SQL:
SELECT payment_method_code ,  party_phone FROM parties WHERE party_email  =  "enrico09@example.com"

Question: What is the payment method code and party phone of the party with the email 'enrico09@example.com'?
SQL:
SELECT payment_method_code ,  party_phone FROM parties WHERE party_email  =  "enrico09@example.com"

Question: Find the emails of parties with the most popular party form.
SQL:
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)

Question: What are the party emails associated with parties that used the party form that is the most common?
SQL:
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)

Question: List all the name of organizations in order of the date formed.
SQL:
SELECT organization_name FROM organizations ORDER BY date_formed ASC

Question: What are the names of organizations, ordered by the date they were formed, ascending?
SQL:
SELECT organization_name FROM organizations ORDER BY date_formed ASC

Question: Find the name of the youngest organization.
SQL:
SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1

Question: What is the name of the organization that was formed most recently?
SQL:
SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1

Question: Find the last name of the latest contact individual of the organization "Labour Party".
SQL:
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

Question: What is the last name of the contact individual from the Labour party organization who was contacted most recently?
SQL:
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

Question: Find the last name of the first ever contact person of the organization with the highest UK Vat number.
SQL:
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

Question: What is the last name of the first individual contacted from the organization with the maximum UK Vat number across all organizations?
SQL:
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

Question: How many services are there?
SQL:
SELECT count(*) FROM services

Question: Count the number of services.
SQL:
SELECT count(*) FROM services

Question: Find name of the services that has never been used.
SQL:
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

Question: What are the names of the services that have never been used?
SQL:
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

Question: Find the name of all the cities and states.
SQL:
SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses

Question: What are the names of all cities and states?
SQL:
SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses

Question: How many cities are there in state "Colorado"?
SQL:
SELECT count(*) FROM addresses WHERE state_province_county  =  "Colorado"

Question: Count the number of cities in the state of Colorado.
SQL:
SELECT count(*) FROM addresses WHERE state_province_county  =  "Colorado"

Question: Find the payment method code used by more than 3 parties.
SQL:
SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING count(*)  >  3

Question: What are the payment method codes that have been used by more than 3 parties?
SQL:
SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING count(*)  >  3

Question: Find the name of organizations whose names contain "Party".
SQL:
SELECT organization_name FROM organizations WHERE organization_name LIKE "%Party%"

Question: What are the names of organizations that contain the word "Party"?
SQL:
SELECT organization_name FROM organizations WHERE organization_name LIKE "%Party%"

Question: How many distinct payment methods are used by parties?
SQL:
SELECT count(DISTINCT payment_method_code) FROM parties

Question: Count the number of different payment method codes used by parties.
SQL:
SELECT count(DISTINCT payment_method_code) FROM parties

Question: Which is the email of the party that has used the services the most number of times?
SQL:
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

Question: Return the party email that has used party services the greatest number of times.
SQL:
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

Question: Which state can address "6862 Kaitlyn Knolls" possibly be in?
SQL:
SELECT state_province_county FROM addresses WHERE line_1_number_building LIKE "%6862 Kaitlyn Knolls%"

Question: Give the state corresponding to the line number building "6862 Kaitlyn Knolls".
SQL:
SELECT state_province_county FROM addresses WHERE line_1_number_building LIKE "%6862 Kaitlyn Knolls%"

Question: What is the name of organization that has the greatest number of contact individuals?
SQL:
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

Question: Return the name of the organization which has the most contact individuals.
SQL:
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

Question: Find the last name of the individuals that have been contact individuals of an organization.
SQL:
SELECT DISTINCT t1.individual_last_name FROM individuals AS t1 JOIN organization_contact_individuals AS t2 ON t1.individual_id  =  t2.individual_id

Question: What are the last names of individuals who have been contact individuals for an organization?
SQL:
SELECT DISTINCT t1.individual_last_name FROM individuals AS t1 JOIN organization_contact_individuals AS t2 ON t1.individual_id  =  t2.individual_id