我有两个单独的案例陈述,它们产生了正确的结果:
Case when A_staff_Service_Type.type = 'v'
then isnull(Indirect_Duration,0)/60.00 else null end以上产品为1名员工生产6.5台。
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的临床应用程序中的查询编写器。
发布于 2015-10-29 14:06:12
我不知道你是什么意思,但我想你是在寻找这样的东西:
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 -但根据你提供的小信息,这是不可能回答的。
“我希望结果被添加”的明显答案是:
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 Endhttps://dba.stackexchange.com/questions/119558
复制相似问题