Updated an SQL query to reflect recent schema changes.