human
Schema:
county (County_Id, County_name, Population, Zip_code)
party (Party_ID, Year, Party, Governor, Lieutenant_Governor, Comptroller, Attorney_General, US_Senate)
election (Election_ID, Counties_Represented, District, Delegate, Party, First_Elected, Committee)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the name of each party and the corresponding number of delegates from that party.
assistant
SELECT T2.Party , COUNT(*) FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID GROUP BY T1.Party
human
Return all the committees that have delegates from Democratic party.
assistant
SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = 'Democratic'
human
Show the name of the party that has at least two records.
assistant
SELECT Party FROM party GROUP BY Party HAVING COUNT(*) >= 2
human
Show all the distinct districts for elections.
assistant
SELECT DISTINCT District FROM election
human
Show the delegate and committee information of elections.
assistant
SELECT Delegate , Committee FROM election
human
Return all the information for each election record.
assistant
SELECT * FROM election ;