日期:2014-05-19  浏览次数:20447 次

一个查询中的字查询,请问怎么在子查询返回空行时显示我指定的字符

形如:
(select   cSid   from   approve_currentStep   where   cEid=approve_STable.eId   and   cPassed=0))   as   '有记录 ' "

如果子查询返回空行时怎么让这个值显示我指定的字符,比如“无字符”?

------解决方案--------------------
--try

case when exists(select 1 from approve_currentStep where cEid=approve_STable.eId and cPassed=0)
then
(select rtrim(cSid) from approve_currentStep where cEid=approve_STable.eId and cPassed=0)
else '无记录 '
end
------解决方案--------------------
要不是这样
select case isnull(cSid, ' ') when ' ' then '无记录 ' else cSid from approve_currentStep where cEid=approve_STable.eId and cPassed=0