---
title: "Define CASE in SQL with its Syntax?"  
description: "Define CASE in SQL with its Syntax?"  
author: "Sushant Mishra"  
published: 2017-07-23  
updated: 2020-09-19  
canonical: https://www.mindstick.com/interview/23283/define-case-in-sql-with-its-syntax  
category: "database"  
tags: ["sql server"]  
reading_time: 1 minute  

---

# Define CASE in SQL with its Syntax?

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
expressionWHEN
expression1 THEN expression1[[WHEN
expression2 THEN expression2] [...]] [ELSE expressionN] END
```

**Searched case Expression Syntax**

```
CASEWHEN
Boolean_expression1 THEN expression1[[WHEN
Boolean_expression2 THEN expression2] [...]] [ELSE expressionN] END
```

## Answers

### Answer by Sushant Mishra

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
expressionWHEN
expression1 THEN expression1[[WHEN
expression2 THEN expression2] [...]] [ELSE expressionN] END
```

**Searched case Expression Syntax**

```
CASEWHEN
Boolean_expression1 THEN expression1[[WHEN
Boolean_expression2 THEN expression2] [...]] [ELSE expressionN] END
```


---

Original Source: https://www.mindstick.com/interview/23283/define-case-in-sql-with-its-syntax

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
