SQL Query Order of Operations