sql server - how to convert the below subquery into joins using one update statement -
below complete query have , ultimate aim update claim table. should 1 statement without subquery, joins allowed because going run in appliance won't support subquery:
declare @decwdrwn table(ctryid smallint, cmid int, decwdrwndt int); s ( select ctryid,cmid,dt, isnull(( select max(cmhistdttmid) claimhistory l st = 3 , l.ctryid = c.ctryid , l.cmid = c.cmid) , 0) maxdec, isnull(( select max(cmhistdttmid) claimhistory l st = 7 , l.ctryid = c.ctryid , l.cmid = c.cmid) , 0) maxset claimhistory c st =3 ) insert @decwdrwn select ctryid, cmid, max(dt) decdt s maxset > maxdec group ctryid,cmid
your response appreciated...
update claims set cmdclnwdwndt = ( select decwdrwndt @decwdrwn d d.cmid = claims.cmid , d.ctryid = claims.ctryid ) exists ( select * @decwdrwn d d.cmid = claims.cmid , d.ctryid = claims.ctryid )
please try inner join update:
update set a.cmdclnwdwndt = b.decwdrwndt claims a, @decwdrwn b a.cmid = b.cmid , a.ctryid =b.ctryid
Comments
Post a Comment