當 WHEN 子句評估為 true時的結果。
語法
WHEN when_expression THEN then_expression
論點
when_expression
任何有效的布爾表達式。
then_expression
傳回集合的任何有效查詢表達式。
備註
如果 when_expression 評估為 值 true,則結果會是對應的 then-expression。 如果未滿足任何 WHEN 條件, else-expression 則會評估 。 不過,如果沒有 else-expression,則結果為 null。
如需範例,請參閱 CASE。
範例
下列 Entity SQL 查詢會使用 CASE 運算式來評估一組 Boolean 運算式。 查詢是以 AdventureWorks 銷售模型為基礎。 若要編譯並執行此查詢,請遵循下列步驟:
遵循 如何:執行傳回 PrimitiveType 結果的查詢中的程式。
將下列查詢當做自變數傳遞至
ExecutePrimitiveTypeQuery方法:
CASE WHEN AVG({@score1,@score2,@score3}) < @total THEN TRUE ELSE FALSE END
另請參閱
- 案例 (Assuming "CASE" refers to an instance or example. Adjust as necessary based on additional context.)
- Entity SQL 參考