oracle增加一条学生信息,SQL oracle添加一个值(SQL oracle add a value)

SQL oracle添加一个值(SQL oracle add a value)

假设我想选择有奖学金的学生并加上这个价值150,对于那些没有奖学金的学生来说,我要加上100.我试过:

选择名称,奖学金+ 150作为“新奖学金”的学生,其中法氏囊不是联合选择名称,奖学金+ 100作为“新奖学金”来自学生,其中法氏囊无效;

但只有那些有奖学金的人才能增加新的价值。请你帮助我

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

原文:https://stackoverflow.com/questions/40201849

更新时间:2020-02-20 09:44

最满意答案

如果奖学金可能为NULL,则将其替换为nvl(奖学金,0)或合并(奖学金,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) ...

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) ...

2016-10-23

相关问答

为什么不呢:)谢谢你,我希望它是直截了当的。 我将nvl()函数添加到net和tax列。 所以现在看起来像这样: to_char(nvl(INVOICE_NET,0) + nvl(INVOICE_TAX,0), '9,999,999.99') AS GROSS_PRICE

非常感谢你的帮助wxyz Why not indeed :) Thank you , I was hoping it was something straight forward. I added nvl() functio

...

您可以使用窗口函数来计算ID: select word,

cnt,

dense_rank() over (order by word) as id

from the_table;

如果你真的需要坚持下去,你可以使用上面的表来更新表: merge into the_table tg

using (

select rowid as rid,

dense_rank() over (order by word) as new_id

from th

...

你可以使用regex_like WHERE REGEXP_LIKE (CUSTOMER_ADDRESS , '^[A-Z]');

You could use regex_like WHERE REGEXP_LIKE (CUSTOMER_ADDRESS , '^[A-Z]');

如果你总是有相同的长度字符串(4位+'0'+ 2位),你可以简单地将其子串:(添加闰年逻辑) DECLARE lvchInput VARCHAR2(7);

lvchOutput VARCHAR2(7);

lnYear NUMBER;

lnWeek NUMBER;

lbLeap BOOLEAN;

BEGIN

lvchInput := '2012052';

lnYear := to_n

...

你可以这样做, SELECT 'UPCOMING FLIHGTS' text, NULL sched

FROM dual

UNION ALL

UNION ALL

SELECT 'PAST FLIGHTS' text, NULL sched

FROM dual

UNION ALL

you can do it this way, SELE

...

不,你不会丢失数据 您可以创建列表分区并在默认分区上展开它 例如,如果您的分区是日期: alter table your_table split partition PDEFAULT values(TO_DATE('20161206','yyyymmdd')) into ( partition P20161206,partition PDEFAULT)

No you dont lose the data You can create list partition and expand it on

...

在Sql-Developer中,您需要单击右侧的表, 然后选择“数据”选项卡,然后插入新行(或选择现有行), 接下来单击BLOB列,在下面的对话框中单击“加载”选项, 然后选择一个图像并将其从本地光盘上传到表格 见附图。 In Sql-Developer, you neet to click on the table on the right side, then select "Data" tab, then insert new row (or select existing row), ne

...

如果奖学金可能为NULL,则将其替换为nvl(奖学金,0)或合并(奖学金,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) ...

If scholarship might be NULL

...

我相信你想要这样的东西: SELECT A.Id, SUM(B.Price) TotalPrice

FROM ( SELECT *

FROM Table1

WHERE Something) A

LEFT JOIN Table2 B

ON A.Id = B.Table1_id

GROUP BY A.Id

I believe you want something like this: SELECT A.Id, SUM(B.Price) TotalPrice

FROM

...

您可以通过两个步骤完成: SQL> WITH DATA AS (

2 SELECT 1 id, 'AA' name FROM DUAL

3 UNION ALL SELECT 2 id, 'AA' name FROM DUAL

4 UNION ALL SELECT 3 id, 'AA' name FROM DUAL

5 UNION ALL SELECT 4 id, 'MB' name FROM DUAL

6 UNION

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值