如何根据查询创建基于数据的新列

发布于 2025-02-12 14:05:17 字数 251 浏览 1 评论 0原文

我有一个快速的问题。

附加SS供参考。

如果ID为null,则如何将新列“状态”设置为NO基于NVL条件,则我必须映射到另一个表的相应。

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 .

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘虞初梦 2025-02-19 14:05:17

您可以使用案例语句来执行此操作。

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(+)

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(+)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文