Sdílet prostřednictvím


THEN

The result of a WHEN clause when it evaluates to true.

WHEN when_expression THEN then_expression

Arguments

  • when_expression
    Any valid Boolean expression.
  • then_expression
    Any valid query expression that returns a collection.

Remarks

If when_expression evaluates to the value true, the result is the corresponding then-expression. If none of the WHEN conditions are satisfied, the else-expression is evaluated. However, if there is no else-expression, the result is null.

For an example, see CASE.

Example

The following Entity SQL query uses the CASE expression to evaluate a set of Boolean expressions. The query is based on the AdventureWorks Sales Model. To compile and run this query, follow these steps:

  1. Follow the procedure in How to: Execute a Query that Returns PrimitiveType Results.

  2. Pass the following query as an argument to the ExecutePrimitiveTypeQuery method:

CASE WHEN AVG({@score1,@score2,@score3}) < @total THEN TRUE ELSE FALSE END

See Also

Reference

WHEN
CASE

Concepts

Entity SQL Reference