0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SQLで簡単な条件分岐CASEを使う

Posted at

SQLで条件に合わせて値を変える

SELECT
    CASE
        WHEN 条件1 THEN 1
        WHEN 条件2 THEN 2
        ELSE 3
    END AS 列名

SELECT
    CASE
        WHEN age < 20 THEN '未成年'
        WHEN age < 65 THEN '成人'
        ELSE '高齢者'
    END AS age_group
FROM
    users
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?