Fix broken SQL query.