SELECT [ ALL | DISTINCT ]
[TOP ( expression ) [PERCENT] [ WITH TIES ] ]
column_list
[ INTO new_table ]
[ FROM { table_source } [ ,...n ] ]
[ WHERE expression1 operator expression2 -- eval highest level operators first
[ GROUP BY ]
[ HAVING search_condition ]
[ ORDER BY order_expression [ ASC | DESC ]
PURPOSE:
Operator precedence determines the sequence that operations are performed when evaluating a complex expression.
| Level | Operator |
| 1 | inner parenthesis |
| 2 | outer parenthesis |
| 3 | ~ (Bitwise NOT) |
| 4 | * (Multiply), / (Division), % (Modulo) |
| 5 | + (Positive), – (Negative), + (Add), (+ Concatenate), – (Subtract), & (Bitwise AND), ^ (Bitwise Exclusive OR), | (Bitwise OR) |
| 6 | =, >, < , >=, < =, <>, !=, !>, !< (Comparison operators) |
| 7 | NOT |
| 8 | AND |
| 9 | ALL, ANY, BETWEEN, IN, LIKE, OR, SOME |
| 10 | = (Assignment) |
NOTE: When operators are at same level, proceed left to right – just as in reading.