Exercise in using SQL queries in Ruby