Let`s say I want to select the students with scholarship and add to that value 150 and for those with no scholarship to add 100.I tried :
select name,scholarship+150 as "New scholarship" from students where bursa is not null union select name,scholarship+100 as "New scholarship" from students where bursa is null;
but only for those who had scholarship added the new value .Can you please help me
If scholarship might be NULL replace it with nvl(scholarship,0) or coalesce(scholarship,0)
select scholarship + case when bursa is not null then 150 else 100 end ...
or
select scholarship + decode (bursa,null,100,150) ...
or
select scholarship + nvl2 (bursa,150,100) ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With