「Oracle入門」CASE WHEN条件式の書き方

2018年11月17日

方法1

SELECT
    CASE MEMBER.USERNO
        WHEN 51 THEN 'KDF'
        WHEN 52 THEN 'KDF'
        WHEN 33 THEN 'JSS'
        WHEN 34 THEN 'JSS'
        ELSE 'CFT'
    END
FROM MEMBER;

方法2

SELECT
    CASE
        WHEN MEMBER.USERNO = 51 OR MEMBER.USERNO = 52 THEN 'KDF'
        WHEN MEMBER.USERNO = 33 OR MEMBER.USERNO = 34 THEN 'JSS'
        ELSE 'CFT'
    END
FROM MEMBER;

Oracle

Posted by arkgame