SQL query for exercise 1