What's the complete and proper syntax for that SQL Situation statement?
The complete syntax is dependent around the database engine you are dealing with:
For SQL Server:
CASE case-expression WHEN when-expression-1 THEN value-1 [ WHEN when-expression-n THEN value-n ... ] [ ELSE else-value ] END
CASE WHEN boolean-when-expression-1 THEN value-1 [ WHEN boolean-when-expression-n THEN value-n ... ] [ ELSE else-value ] END
case-expression - something that produces a value when-expression-x - something that is compared against the case-expression value-1 - the result of the CASE statement if: the when-expression == case-expression OR the boolean-when-expression == TRUE boolean-when-exp.. - something that produces a TRUE/FALSE answer
Also observe that the ordering from the WHEN claims is essential. It is simple to write multiple WHEN clauses that overlap, and the first that suits can be used.
Note: If no ELSE clause is specified, with no matching WHEN-condition is located, the need for the Situation expression is going to be NULL.
Listed here are the good examples in the PostgreSQL paperwork (Postgres follows the conventional here):
CASE WHEN a=1 THEN 'one'
WHEN a=2 THEN 'two'
CASE a WHEN 1 THEN 'one'
WHEN 2 THEN 'two'