[英]SQL Subquery as expression
我有以下两个表:
Create Table #Claims (ClaimId int, FormType varchar(3), AdjustmentVersion int)
Create Table #Secondary (FeeId int, FeeName varchar(60))
我希望能够返回所有属于特定 FormType 和 AdjustmentVersion 的声明。
鉴于以下查询:
select * from #Claims where FormType = 'DEN' and AdjustmentVersion in (1,2,3,(select FeeId from #Secondary))
如何更正语法以同时匹配给定整数和子查询上的 AdjustmentVersion? 目前,我收到错误“子查询返回了多个结果”。
我尝试使用和或与 AdjustmentVersion 但最终忽略了 FormType = 'DEN'
您可以将值分成两组,文字和子查询:
select *
from #Claims
where FormType = 'DEN' and
( AdjustmentVersion in (1,2,3) or AdjustmentVersion in (select FeeId from #Secondary) );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.