A CASE statement is used to perform different actions based on different conditions. It is similar to an IF-THEN-ELSE statement, but with more than one condition.A NESTED CASE statement is a CASE statement that is used within another CASE statement. It allows you to test for multiple conditions within a single CASE statement.CASE statement is used for selection or setting a new value from a given set of values. It can be used in SELECT, UPDATE and DELETE statements. Nested CASE statement is used when there are multiple conditions to be checked. The inner CASE statement is executed first and the outer CASE statement is executed next.CASE statement is used to test a condition and return a value based on the result of the test. Nested CASE statement is used when there are multiple conditions to be tested. In SQL Server, you can use CASE in the SELECT list, WHERE clause, and ORDER BY clause.CASE statement syntax:CASEWHEN condition1 THEN result1ELSE result3CASE statement is used for various purposes such as to return different values on the basis of some conditions, to execute different code blocks based on some conditions, and so on. It can be used in various places such as in a SELECT clause, in a WHERE clause, or even in an ORDER BY clause.
Nested CASE statement is nothing but multiple CASE statements written inside each other. It is generally used when there are more than two conditions to be evaluated.SQL Server provides the CASE statement that allows you to select or display a result set based on conditions that you specify. You can use the CASE statement in a SELECT, UPDATE, or DELETE statement.The CASE statement has two forms: simple and searched. The simple CASE statement compares an expression to a set of discrete values and returns the corresponding value from another expression. The searched CASE statement evaluates a list of Boolean expressions to return one of the specified values.If none of the WHEN conditions are TRUE, the CASE statement returns the value in the ELSE clause, if an ELSE clause exists. If no WHEN clause is TRUE and no ELSE clause exists, no value is returned.The CASE statement is a control statement that allows you to select one of a number of options based on a condition. It is useful for tasks such as:-Selecting an action to perform based on the value of an expressionAssigning a value to a variable based on the value of an expressionPrinting different messages depending on the value of an expressionThe CASE statement has two forms: simple and searched. The simple form evaluates an expression and, if the result is TRUE, executes a statement. If the result is FALSE, it skips the statement. The searched form evaluates multiple conditions and, when it finds one that is TRUE, executes a corresponding SQL Server statement. If no conditions are TRUE, it skips all statements in the CASE block.