Fixed an error in SQL queery