order of clauses in sql query