gpt4 book ai didi

SQL oracle 添加一个值

转载 作者:行者123 更新时间:2023-12-04 23:47:20 24 4
gpt4 key购买 nike

假设我想选择有奖学金的学生并在该值上加 150,为没有奖学金的学生加 100。我试过了:

select name,scholarship+150 as "New scholarship"from students which bursa is null union select name,scholarship+100 as "New scholarship"from students which bursa is null;

但只对那些有奖学金的人增加了新的值(value)。你能帮帮我吗

最佳答案

如果 scholarship 可能为 NULL,将其替换为 nvl(scholarship,0)coalesce(scholarship,0)

select scholarship + case when bursa is not null then 150 else 100 end ...

select scholarship + decode (bursa,null,100,150) ...

select scholarship + nvl2 (bursa,150,100) ...

关于SQL oracle 添加一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40201849/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com