这个sql有什么毛病?请帮我看看,谢谢

bsd 2002-11-22 09:47:26

CREATE VIEW employee_view
AS
select a.objid, a.employee_id, a.local_name,
english_name = isNull(b.english_name,a.english_name),
a.email,
department = isNull(b.department,a.org_name) ,
a.proxy_id,
status = IIf(a.on_duty,'resign','on duty'),
a.extension
from employee_a as a left join employee_b as b
on a.employee_id = b.employee_id
...全文
31 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
leimin 2002-11-22
  • 打赏
  • 举报
回复
iif()中第一个参数不是可以为logical expression,你要加个判断,比如isnumeric(a.on_duty)或你自定义一个函数,返回1/0.
bsd 2002-11-22
  • 打赏
  • 举报
回复
谢谢。
不过很奇怪,难道IIF不能这么用吗?
第一个参数不是可以为logical expression?
j9988 2002-11-22
  • 打赏
  • 举报
回复
是用SQL SERVER ?
status = IIf(a.on_duty,'resign','on duty')---->

status = (case when a.on_duty=1 then 'resign' else 'on duty' end)
pengdali 2002-11-22
  • 打赏
  • 举报
回复
CREATE VIEW employee_view
AS
select a.objid, a.employee_id, a.local_name,
english_name = isNull(b.english_name,a.english_name),
a.email,
department = isNull(b.department,a.org_name) ,
a.proxy_id,
status = case when a.on_duty=1 then 'resign' else 'on duty' end,
a.extension
from employee_a as a left join employee_b as b
on a.employee_id = b.employee_id

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧