Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sql查询中除法、乘法、减法的执行顺序_Sql_Sql Server - Fatal编程技术网

sql查询中除法、乘法、减法的执行顺序

sql查询中除法、乘法、减法的执行顺序,sql,sql-server,Sql,Sql Server,我在SQL查询中使用了加法“+”、乘法“*”和除法“/”运算符。 它的执行顺序是什么 质疑 Select A * (B) - C * 100 / (D-E) From Table 和其他的一样。。。基于彭达斯 Parenthesis Exponents Multiply and Divide at same level, left to right Add and Subtract at same level left to right. (D-E) is don

我在SQL查询中使用了加法“+”、乘法“*”和除法“/”运算符。 它的执行顺序是什么

质疑

Select A * (B) - C * 100 / (D-E) From Table

和其他的一样。。。基于彭达斯

Parenthesis

Exponents

Multiply 
  and 
Divide at same level, left to right

Add 
  and 
Subtract at same level left to right.




(D-E) is done first
(B) is done next, but is left as-is as no other direct relation 
A * B
C * 100
then 
(result of C * 100) / (D - E result)
(A * B result ) - ( entire C * 100 / (D-E) result)

请看下面的链接

显然,若两个运算符具有相同的存在性,那个么左边的表达式将获得更高的优先级。此外,括号内的表达式将获得最高的存在性

在您的情况下,将首先评估D-E。那么它的左边就是A*B。那么它将是C*100。然后是除法,最后是减法


让我知道我是否正确

看起来像一道考试题。除非它不能正常工作:选择30/3/5;选择30/3/-5;选择30/-3/5