sql query correction