human
Schema:
region (Region_ID, Region_name, Date, Label, Format, Catalogue)
party (Party_ID, Minister, Took_office, Left_office, Region_ID, Party_name)
member (Member_ID, Member_Name, Party_ID, In_office)
party_events (Event_ID, Event_Name, Party_ID, Member_in_charge_ID)
Please answer with SQL.
assistant
Sure, I understand.
human
List member names and their party names.
assistant
SELECT T1.member_name , T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id
human
What is the name of party with most number of members?
assistant
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
human
What are the names of parties with at least 2 events?
assistant
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
human
Show all ministers who do not belong to Progress Party.
assistant
SELECT minister FROM party WHERE party_name != 'Progress Party'
human
Show the ministers and the time they took and left office, listed by the time they left office.
assistant
SELECT minister , took_office , left_office FROM party ORDER BY left_office
human
Who are the ministers and what parties do they belong to, listed descending by the times they took office?
assistant
SELECT minister , party_name FROM party ORDER BY took_office DESC ;