首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >增加2份案例陈述

增加2份案例陈述
EN

Database Administration用户
提问于 2015-10-29 13:59:01
回答 1查看 3.1K关注 0票数 1

我有两个单独的案例陈述,它们产生了正确的结果:

代码语言:javascript
复制
Case when A_staff_Service_Type.type = 'v' 
  then isnull(Indirect_Duration,0)/60.00 else null end

以上产品为1名员工生产6.5台。

代码语言:javascript
复制
Case when pt_service.service_code = 'N06 ' 
  then isnull(direct_Duration,0)/60.00 else null End

以上为同一雇员生产5.5。

因此,我有两个独立的输出,分别为6.5和5.5。我想要的是12的输出,我已经试过了

当A_staff_Service_Type.type = 'v‘然后是null (Indirect_Duration,0)/60.00/60.00 null end +的情况下

当pt_service.service_code = 'N06‘然后是空(direct_Duration,0)/60.00/60.00空结束时

但是上面的结果是0而不是12。

这是基于Server 2008的临床应用程序中的查询编写器。

EN

回答 1

Database Administration用户

回答已采纳

发布于 2015-10-29 14:06:12

我不知道你是什么意思,但我想你是在寻找这样的东西:

代码语言:javascript
复制
Case 
  when A_staff_Service_Type.type = 'v' and pt_service.service_code = 'N06' 
     then isnull(Indirect_Duration,0)/60.00  + isnull(direct_Duration,0)/60.00 
  else null 
end

我也不知道AND对用例是否正确。也许你想要一个OR -但根据你提供的小信息,这是不可能回答的。

“我希望结果被添加”的明显答案是:

代码语言:javascript
复制
Case when A_staff_Service_Type.type = 'v' 
  then isnull(Indirect_Duration,0)/60.00 else 0 end 
+
Case when pt_service.service_code = 'N06 ' 
  then isnull(direct_Duration,0)/60.00 else 0 End
票数 1
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/119558

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档