简体   繁体   中英

How to create a new column based on data out from a query

I have a quick question.

ATtaching the SS for reference.

How can i set a new column 'Status' as NO based the nvl condition if the id is null then i have to map to the corresponding of another table.

在此处输入图像描述

You can do that using case statement.

select
    nvl(b.id,a.id) as id
    ,b.name
    ,case when nvl(b.id,a.id) is null then 'No' else 'Yes' End as Status
from dd b,
(select id, name from demo group by id, name)a
where a.id=b.id(+)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM