Assignment for March 12

SQLite: Download the following CSV files: members, positions and votes, then import them into a new sqlite database using the SQLite Manager for Firefox.

Then, using what we’ve learned about SQL Joins, write queries to answer the following:

  1. Show me how the members from California voted on the Captive Primate Safety Act.
  2. Which Democrat has voted the most often against the majority position of the party?
  3. How many times have at least 10 Republicans voted “Yes” on Approving the Journal

All three of these require joining at least two tables together; two require joining three tables. Remember the join syntax:

SELECT some_field, some_other_field FROM table1 JOIN table 2 ON (table1.field = table2.field) JOIN table3 on (table2.field = table3.field)

You can also join via the WHERE clause:

SELECT some_field, some_other_field FROM table1, table2, table3 WHERE table1.field=table2.field and table2.field = table3.field

Reading: Wichita Eagle on potholes.

Advertisements

About this entry