In SQL CASE is used to provide if-then-else type of logic to SQL. It supports two formats, One is a Simple CASE expression, where we compare an expression to static values and the second is a Searched CASE expression, where we compare an expression to one or more logical conditions
Simple Case Expresseion Syntax
CASE
expression WHEN
expression1 THEN expression1 [[WHEN
expression2 THEN expression2] [...]] [ELSE expressionN] END
Searched case Expression Syntax
CASE WHEN
Boolean_expression1 THEN expression1 [[WHEN
Boolean_expression2 THEN expression2] [...]] [ELSE expressionN] END
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
In SQL CASE is used to provide if-then-else type of logic to SQL. It supports two formats, One is a Simple CASE expression, where we compare an expression to static values and the second is a Searched CASE expression, where we compare an expression to one or more logical conditions
Simple Case Expresseion Syntax
Searched case Expression Syntax