查询返回列的空值,需要用值替换空值。我不知道怎么办。请帮忙

发布于 2024-12-05 05:35:21 字数 694 浏览 1 评论 0原文

SELECT COL1, DATE_END
        FROM TABLE1 
        WHERE COL1 IN('1','2','3','4','5','6','7','8','9','10','11','12')
    ORDER BY 1;

是查询。执行时它给出了我,

COL1   DATE_END
1                                  
2 
3
4
5
6
7
8
9
10
11
12

因为在表中记录 1...12 的 date_end 为 null

方式修改查询

COL1  DATE_END    
1     12/31/9999
2     12/31/9999
3     12/31/9999
4     12/31/9999
5     12/31/9999
6     12/31/9999
7     12/31/9999
8     12/31/9999
9     12/31/9999
10    12/31/9999
11    12/31/9999
12    12/31/9999 

,并且应该以输出为
的 我希望这次我很清楚我在尝试什么

请专家帮助我...提前感谢

我使用了“----”,因为我不知道如何在 HTML 中插入空格

SELECT COL1, DATE_END
        FROM TABLE1 
        WHERE COL1 IN('1','2','3','4','5','6','7','8','9','10','11','12')
    ORDER BY 1;

is the query. and when executed it gives me

COL1   DATE_END
1                                  
2 
3
4
5
6
7
8
9
10
11
12

because in the table the records 1...12 have their date_end as null

and the query should be modified in a way that the output is

COL1  DATE_END    
1     12/31/9999
2     12/31/9999
3     12/31/9999
4     12/31/9999
5     12/31/9999
6     12/31/9999
7     12/31/9999
8     12/31/9999
9     12/31/9999
10    12/31/9999
11    12/31/9999
12    12/31/9999 

I hope I am clear this time, as to what I was trying out

Please help me experts... Thanks in advance

I have used "----" as I did not know how to insert spaces in HTML

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

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

发布评论

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

评论(2

笑,眼淚并存 2024-12-12 05:35:21

使用 COALESCE 函数替换 NULL 值。我也不喜欢在 ORDER BY 子句中使用序数位置,因此我也更改了它。

SELECT COL1, COALESCE(DATE_END, '12/31/9999') AS DATE_END
    FROM TABLE1 
    WHERE COL1 IN('1','2','3','4','5','6','7','8','9','10','11','12') 
    ORDER BY COL1;

Use the COALESCE function to replace the NULL values. I'm also not a big fan of using ordinal positions in the ORDER BY clause, so I changed that as well.

SELECT COL1, COALESCE(DATE_END, '12/31/9999') AS DATE_END
    FROM TABLE1 
    WHERE COL1 IN('1','2','3','4','5','6','7','8','9','10','11','12') 
    ORDER BY COL1;
一城柳絮吹成雪 2024-12-12 05:35:21
SELECT COL1, COALESCE(DATE_END, '12-31-9999') FROM TABLE1 WHERE COL1 IN('1','2','3','4','5','6','7','8','9','10','11','12') ORDER BY 1;
SELECT COL1, COALESCE(DATE_END, '12-31-9999') FROM TABLE1 WHERE COL1 IN('1','2','3','4','5','6','7','8','9','10','11','12') ORDER BY 1;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文