sql query errors resolved