Switch Case In SQL

2022-12-29 16:18:23
SQL hashnode
Switch Case In SQL

Introduction

  1. The case statement in SQL returns a value on a specified condition.

  2. We can use a Case statement in select queries along with Where, Order By, and Group By clauses.

  3. It can be used in the Insert statement as well. In this article, we would explore the CASE statement and its various use cases.

Syntax Of Switch Case

CASE
    WHEN condition1 THEN result1
    WHEN condition2 THEN result2
    WHEN conditionN THEN resultN
    ELSE result
END;

© 2022 开源博客 京ICP备20030565号-2 Powered by Quick API team