SQL queries syntax fixed