Home > database >  Oracle where case when after it
Oracle where case when after it

Time:10-23

Select the name
The from student
Where the age=
(case when sex is not null then '15' end)
When sex=null, the result is what kind of

CodePudding user response:

(case when sex is not null then '15' end)
Equivalent to
(case when sex is not null then '15' else null end)

CodePudding user response:

Nvl2 (sex, '15', null)

CodePudding user response:

When sex=null, what all can't query,
Principle is very simple, when sex=null, that is,
Select a case when a null is not null then '15' end from dual;
Returns the result is null
Select the name
The from student
Where the age=null
This statement is what all can't query,

CodePudding user response:

SELECT the name FROM student
WHERE the age=(CASE WHEN sex is not null THEN '15' ELSE null END)
  • Related