【文件属性】:
文件名称:操作符顺序-SQL语言基础
文件大小:5.26MB
文件格式:PPT
更新时间:2021-04-25 19:38:07
SQL 基础
操作符顺序
*
SQL> SELECT ename, sal, 12*sal+100
2 FROM emp;
ENAME SAL 12*SAL+100
---------- --------- ----------
KING 5000 60100
BLAKE 2850 34300
CLARK 2450 29500
JONES 2975 35800
MARTIN 1250 15100
ALLEN 1600 19300
...
14 rows selected.
*
Operator Precedence (continued)
The example on the slide displays the name, salary, and annual compensation of employees. It calculates the annual compensation as 12 multiplied by the monthly salary, plus a one-time bonus of $100. Notice that multiplication is performed before addition.
Note: Use parentheses to reinforce the standard order of precedence and to improve clarity. For example, the expression above can be written as (12*sal)+100 with no change in the result.
Instructor Note
Demo: l1prec1.sql, l1prec2.sql
Purpose: To illustrate viewing a query containing no parentheses and executing a query with parentheses to override rules of precedence.