kdjonesmtb2
Technical User
Hello
I would like to change the following
Code into CTE so that I can avoid
Using temp tables
drop table #Test1
select
Row_Number() Over(Partition by a.provid order by g.fullname) as Rownumberofaffiliates
, a.affiliationid
, a.effdate
, a.termdate
, g.-- add top 1 for auto script
fullname as site
into #Test1
from dbo.affiliation a
left outer join provider g (nolock) on a.affiliateid = g.provid --Affiliate/Site
where a.provid in ('PRV00002909 ')
and a.affiltype in ('GROUP', 'DIRECT')
select affiliationid as affiliationid from #Test1
where Rownumberofaffiliates = '1'