「Oracle入門」null判定方法を纏める

判定方法下記

1.decode関数
SELECT
  DECODE(USERNAME, NULL, 0, 1) AS NVLFLG
FROM
  USERINFOTBL


2.case条件式
SELECT
  CASE 
    WHEN USER_NAME IS NULL THEN 0 
    ELSE 1 
  END AS NVLFLG
FROM
  USERINFOTBL

3.NUL2関数
SELECT
  NVL2(USER_NAME, 1, 0)  AS NVLFLG
FROM
  USERINFOTBL

Software

Posted by arkgame