34,576
社区成员
发帖
与我相关
我的任务
分享
select (case when username is null then '-' else username end) as UserName from table
select
userid,
case when username IS null
then '-'
else username
end
from tb
select
userid,
ISNULL(username,'-')
from tb
select
case when username is null then '-' else username end
from
table
select
isnull(username,'-')
from
table
select userid,isnull(username,'-')
from table
CREATE TABLE #temp
(
userid INT IDENTITY,
username VARCHAR(10)
)
INSERT #temp
SELECT 'a' UNION ALL SELECT NULL
go
--SQL:
SELECT
userid,
username = CASE WHEN username IS NULL THEN '-' ELSE username END
FROM #temp
/*
1 a
2 -
*/
select case when username is null then '-' else username end from table