Thank you!!! Got that to work this way...
drop table #ESI
go
select prname,pcpteam,hfactname,count(distinct ptien)Uniq,
convert(varchar(2),datepart(mm,visitdate)) + convert(varchar(4),datepart(yyyy,visitdate))as EDdate
into #ESI
from #fh
group by hfactname,pcpteam,prname,visitdate
go
select *...