Database: e_government

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: List all the 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: 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: 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: List all the name of organizations in order of the date formed.
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: 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: 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: Find 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: How many cities are there in state "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: Find the name of organizations whose names contain "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