Fixed an errir in SQL query