Litware Price Groups: In the first T-SQL snippet, which keyword should begin the CASE expression inside the SELECT?

Prepare for the DP-600 Fabric Analytics Engineer Exam. Study with flashcards and multiple choice questions, each offering hints and detailed explanations. Enhance your chances of success on the exam!

Multiple Choice

Litware Price Groups: In the first T-SQL snippet, which keyword should begin the CASE expression inside the SELECT?

Explanation:
The CASE expression in T-SQL is started with the keyword CASE inside a SELECT. That first token signals the beginning of the conditional expression you’re building. After CASE, you supply branches with WHEN ... THEN ... for each condition, and finally END to close the expression. So the keyword that should begin the CASE expression is CASE. For example: SELECT CASE WHEN Amount > 1000 THEN 'High' ELSE 'Low' END AS PriceGroup FROM Orders; Here you see CASE opens the expression, WHEN defines a condition, THEN specifies the result for that condition, and END closes it. The other keywords come after the initial CASE, so they can’t start the expression.

The CASE expression in T-SQL is started with the keyword CASE inside a SELECT. That first token signals the beginning of the conditional expression you’re building. After CASE, you supply branches with WHEN ... THEN ... for each condition, and finally END to close the expression. So the keyword that should begin the CASE expression is CASE.

For example:

SELECT CASE WHEN Amount > 1000 THEN 'High' ELSE 'Low' END AS PriceGroup FROM Orders;

Here you see CASE opens the expression, WHEN defines a condition, THEN specifies the result for that condition, and END closes it. The other keywords come after the initial CASE, so they can’t start the expression.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy