Database: party_people

Question: Show the minister who took office after 1961 or before 1959.
SQL: SELECT minister FROM party WHERE took_office  >  1961 OR took_office  <  1959

Question: Return the minister who left office at the latest time.
SQL: SELECT minister FROM party ORDER BY left_office DESC LIMIT 1

Question: Show all party names and the number of members in each party.
SQL: SELECT T2.party_name ,  count(*) FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id

Question: What is the name of party with most number of members?
SQL: SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id ORDER BY count(*) DESC LIMIT 1

Question: Show names of parties that does not have any members.
SQL: SELECT party_name FROM party WHERE party_id NOT IN (SELECT party_id FROM Member)

Question: Show the member names which are in both the party with id 3 and the party with id 1.
SQL: SELECT member_name FROM member WHERE party_id  =  3 INTERSECT SELECT member_name FROM member WHERE party_id  =  1

Question: Show member names that are not in the Progress Party.
SQL: SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id WHERE T2.Party_name != "Progress Party"

Question: Show party names and the number of events for each party.
SQL: SELECT T2.party_name ,  count(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id

Question: Show all member names who are not in charge of any event.
SQL: SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id  =  T2.member_in_charge_id

Question: What are the names of parties with at least 2 events?
SQL: SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id  =  T2.party_id GROUP BY T1.party_id HAVING count(*)  >=  2

Question: What is the name of member in charge of greatest number of events?
SQL: SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id  =  T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1

Question: find the event names that have more than 2 records.
SQL: SELECT event_name FROM party_events GROUP BY event_name HAVING count(*)  >  2