Aug. 4 Homework Answers

  1. SELECT COUNT(id) FROM senate_votes WHERE gop_yes=0 and dem_no=0 and gop_not_voting=0 and dem_not_voting=0
  2. SELECT last_name, first_name, COUNT(senate_positions.position) FROM senate_votes JOIN senate_positions ON senate_votes.id=senate_positions.senate_vote_id JOIN members ON senate_positions.member_id = members.id WHERE party ='D' AND position = 'No' GROUP BY last_name, first_name ORDER BY COUNT(senate_positions.position) DESC
  3. SELECT last_name, first_name, COUNT(members.id) FROM senate_votes JOIN senate_positions ON senate_votes.id=senate_positions.senate_vote_id JOIN members ON senate_positions.member_id = members.id WHERE (members.party)="R" AND senate_positions.position=senate_votes.gop_majority_position GROUP BY last_name, first_name ORDER BY COUNT(senate_positions.position) DESC
  4. SELECT last_name, first_name, COUNT(members.id) FROM senate_votes JOIN senate_positions ON senate_votes.id=senate_positions.senate_vote_id JOIN members ON senate_positions.member_id = members.id WHERE position ='Not Voting' GROUP BY 1, 2 ORDER BY 3 DESC
  5. SELECT COUNT(id) FROM senate_votes WHERE total_no=0
  6. SELECT last_name, first_name, COUNT(senate_positions.position) FROM senate_votes JOIN senate_positions ON senate_votes.id=senate_positions.senate_vote_id JOIN members ON senate_positions.member_id = members.id WHERE senate_votes.total_no=1 and senate_positions.position='No' GROUP BY last_name, first_name ORDER BY 3 desc
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s