Sql case when multiple conditions
- case statement in sql server query
- case statement in sql server update query
- select query inside case statement in sql server
- case statement in insert query in sql server
Sql case statement in where clause multiple values
If else in sql server!
Overview of Case in real life!
Again, in real life, we perform different actions depending upon the outcome of different conditions.
To elaborate more, consider below example:
- If flight tickets are less than $100, then I will visit Los Angeles.
- If flight tickets are between $100 to $200, then I will visit New York
- If flight tickets are between $200 to $400, then I will visit Europe
- Else, I will prefer to visit some nearby tourist spot.
Let’s consider categorizing Condition and Action separately from the above example below:
Conditions – Flight Tickets | Actions performed, only if Condition is TRUE |
Less than $100 | Visit Los Angeles |
Between $100 to $200 | Visit New York |
Between $200 to $400 | Visit Europe |
None of the above condition met | Nearby tourist spot |
In the above example, we can see that the outcome of the different conditions is governing separate action.
E.g., Visitor will perform the act of visiting New York only in the condition if the flight ticket is between $100 to $200.
Similarly, MS SQL CASE statement also provides the capabilit
- case query example
- case when statement in sql server