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
Liked By
Write Answer
Define CASE in SQL with its Syntax?
Join MindStick Community
You have need login or register for voting of answers or question.
Sushant Mishra
23-Jul-2017In 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