Order of execution of searched CASE expression

0

The CASE WHEN has two ways to function, with simple expressions and searched:

  

The expression simple CASE compares an expression with a set of   simple expressions to determine the result.

     

The expression searched CASE evaluates a set of Boolean expressions   to determine the result.

In the documentation it is said that the CASE WHEN for the first statement is satisfactory, but in some situations the expression is evaluated first:

  

The CASE statement evaluates its conditions in sequence and   first satisfactory condition. In some situations, an expression is   evaluated before a CASE instruction receives the results of the   expression as your input. There may be errors in the evaluation   of these expressions. Aggregated expressions that appear in arguments   WHEN of a CASE statement are evaluated first, and then   provided for the CASE statement.

CASE - Transect SQL

I was unsure how SQL executes the statements in the order in which it le the expressions, more specific in the example below:

CASE
   WHEN validado = 0 THEN 
    1
   WHEN (SUBQUERY COM FUNÇÃO DE AGREGAÇÃO) > 0 THEN
    2
   WHEN MAX(valor) > 0 THEN 
    3
END

If the first expression is true, will sql not execute the subquery?

    
asked by anonymous 14.11.2017 / 16:39

0 answers