Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone tell me the syntax for CASE statement in SQL?

1 Answer

0 votes
by (119k points)

CASE statements are just like the If-else statement in any programming language. In Case statements, we write the conditions, if conditions are met then it returns the result. If the condition is not met, then it returns the result in the ELSE clause. It returns null if no conditions are met and there is no ELSE clause.

Here is the CASE statement syntax in SQL:

CASE
    WHEN condition_1 THEN result_1
    WHEN condition_2 THEN result_2
    WHEN condition_N THEN result_N
    ELSE result
END;

If you want to learn SQL, you can check out this SQL tutorial blog by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 18, 2019 in Big Data Hadoop & Spark by Aarav (11.4k points)
0 votes
1 answer
asked Oct 19, 2020 in SQL by dev_sk2311 (45k points)
0 votes
1 answer
asked Dec 22, 2020 in SQL by Appu (6.1k points)

Browse Categories

...