[英]How to replace the column value in select statement in Sql?
I am trying to write a query like i want to replace the column value with Available if its not empty otherwise Not Available. 我正在尝试编写一个查询,如果我想将列值替换为Available,如果它不为空,否则不可用。
select CandidateID,ResumeName from dbo.Tbl_Candidates
where CreatedBy=UserId order by CandidateID DESC
In this case if ResumeName is not empty i want to replace with Available else Not Available.This help me out to get this. 在这种情况下,如果ResumeName不为空,我想替换为可用其他不可用。这有助于我得到这个。 Thanks in advance.
提前致谢。
select CandidateID, case when ResumeName = '' Then 'Not Available' Else 'Available' End as Availability
from dbo.Tbl_Candidates
where CreatedBy=UserId
order by CandidateID DESC
select CandidateID,
case
when ResumeName is null then 'Not Available'
when ResumeName = '' then 'Not Available'
else 'Available'
end as ResumeName from dbo.Tbl_Candidates
where CreatedBy=UserId order by CandidateID DESC
SELECT CandidateID,CASE WHEN ISNULL(ResumeName,'') = '' 'Not Available' ELSE 'Available' END AS ResumeAvailability from dbo.Tbl_Candidates
where CreatedBy=UserId order by CandidateID DESC
select CandidateID,ISNULL(ResumeName,'Not Available') as ResumeName
from dbo.table
where CreatedBy=UserId order by CandidateID DESC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.