Skip to content

Instantly share code, notes, and snippets.

@cmh114933
Last active June 13, 2019 20:43
Show Gist options
  • Save cmh114933/1ee5644cb15a4ae27d98b5e1ba29f299 to your computer and use it in GitHub Desktop.
Save cmh114933/1ee5644cb15a4ae27d98b5e1ba29f299 to your computer and use it in GitHub Desktop.
  1. Count the votes for Sen. Olympia Snowe, whose id is 524.
votes
-------
23
  1. Now do that query with a JOIN statement without hard-coding the id 524 explicitly, querying both the votes and congress_members table.
votes
-------
23
  1. How about Rep. Erik Paulsen? How many votes did he get?
votes
-------
21
  1. Make a list of Congress members that got the most votes, in descending order. Exclude the create_at and updated_at columns.
name                  votes
--------              --------
Rep. Dan Benishek     32
Rep. Tammy Baldwin    31
Rep. Dale Kildee      31
Rep. Jim Costa        31
Rep. Frank Pallone    31
Sen. Maria Cantwell   30
Rep. Ruben Hinojosa   29
Rep. Marcia Fudge     29
Rep. Devin Nunes      28
Sen. Ron Johnson      28
Rep. Scott DesJarlais 28
Rep. Zoe Lofgren      28
.
.
.
  1. Now make a list of all the Congress members that got the least number of votes, in ascending order. Again, skip the date columns.
name                      votes
--------                  --------
Rep. Mike Rogers          6
Rep. Jim Sensenbrenner    7
Rep. Bill Cassidy         7
Rep. Tim Huelskamp        8
Rep. Ileana Ros-Lehtinen  8
Rep. Alan Nunnelee        9
.
.
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment