SQL查询如果选择条件为空,则输出为文本
我试图添加到现有的SQL查询中,以在整个查询为空时输出“未找到数据” 我想显示“未找到数据”,而不是显示空白输出 我正在编写的SQL查询是针对系统间缓存的。非常感谢您的帮助 这就是我正在处理的问题SQL查询如果选择条件为空,则输出为文本,sql,intersystems-cache,Sql,Intersystems Cache,我试图添加到现有的SQL查询中,以在整个查询为空时输出“未找到数据” 我想显示“未找到数据”,而不是显示空白输出 我正在编写的SQL查询是针对系统间缓存的。非常感谢您的帮助 这就是我正在处理的问题 SELECT Case when sn.1_code = 1 then 'Attended -- ' || sn.mult_1 || 'and' ||
SELECT Case
when sn.1_code = 1 then 'Attended -- ' ||
sn.mult_1 ||
'and' ||
sn.dict_2 ||
' also acted with ' ||
sn.dict_3 ||
'.'
when sn.1_code = 3 then 'left because ' ||
sn.mult_2 ||
'.'
when sn.dict_1 = 2 then 'Went home'
when sn.dict_1 = 24 then 'Canceled' END AS 'Attendance',
sn.dict_2 AS 'Continue'
FROM db.sn
Where sn.dict_2 = 123
如果基于where子句的查询为NULL,则输出应显示文本“今天找不到123的数据”,而不是在我的系统上显示的空白屏幕。如果不为空,则将显示数据
IF Query isnull output should show
NO DATA FOUND FOR 123 TODAY
If Query not isnull output should show
Attendance: Continue:
Attended today. Also Acted with respect Great
Left because not feeling well Excussed
Went Home Not Excused
谢谢用
IsNull
环绕案例
:
SELECT
IsNull(
CASE
when sn.1_code = 1
then 'Attended -- ' ||
sn.mult_1 ||
'and' ||
sn.dict_2 ||
' also acted with ' ||
sn.dict_3 ||
'.'
when sn.1_code = 3
then 'left because ' ||
sn.mult_2 ||
'.'
when sn.dict_1 = 2
then 'Went home'
when sn.dict_1 = 24
then 'Canceled'
END , 'No Data Found' ) AS 'Attendance'
FROM db.sn
感谢您的回复,但我必须在选择标准中添加一个附加列。但是,如果isnull用于输出“未找到数据”Dagz200,则我需要它用于整个选择条件:您编辑的查询每行返回两列。您能否提供一些示例,说明您希望数据如何输出?Dagz200:因此,您希望根据行数定制您的响应,而不是数据中的空条件,对吗?好的,如果行数=0,我们可以尝试显示“今天找不到123的数据”,否则显示找到的数据。你能告诉我怎么做吗?我以前从来没有做过。谢谢,我没有缓存。您是否将此用作自定义程序的提要?