将 NULL 替换为空白值 OS400

发布于 2025-01-20 18:04:24 字数 69 浏览 4 评论 0原文

我试图让我的结果设置为空白而不是空,我尝试了

凝聚 当'y'然后hhhinvn''' 结尾为“信用备忘录号”,

I am trying to get my result set to return a blank rather than NULL, I have tried COALESCE but just cannot seem to get this to work, here is that section of my query:

CASE HHHCRIN
WHEN 'Y' THEN HHHINVN ELSE ''
END AS "Credit Memo Document Number",

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

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

发布评论

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

评论(2

揽清风入怀 2025-01-27 18:04:25

您必须首先使用 COALESCE 命令来列出空值,然后在生成的 COALESCE 新列中包含 CASE 命令,以将空值替换为空白

You have to start with the COALESCE command first to list your nulls, then include a CASE command to your resulting COALESCE new column to replace your nulls with blanks

泅人 2025-01-27 18:04:25

Cocece左至右工作,并将您的第一个非零事物归还了该顺序;

SELECT
  COALESCE(name,address,'unknown value')
FROM Person

“如果名称为null,请尝试地址,如果地址为null,请尝试'未知值' - 和'未知值'绝对不是null”,

对于下表:

Name,Address,  COALESCE returns
John,The Road, John
John,NULL,     John
NULL,The Road, The Road
NULL,NULL,     unknown value

COALESCE works left to right and returns you the first non null thing encountered in that order;

SELECT
  COALESCE(name,address,'unknown value')
FROM Person

"If name is null, try address, if address is null, try 'unknown value' - and 'unknown value' is definitely not null"

For the following table:

Name,Address,  COALESCE returns
John,The Road, John
John,NULL,     John
NULL,The Road, The Road
NULL,NULL,     unknown value
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文