我试图将两个表连接起来,这些表有大约870,000条记录(每个表)。 我必须加入date和varchar字段。 我知道这是最糟糕的组合。 我尝试将Date Fields转换为int,并索引我在两个表中加入的所有列。 这个查询永远都是需要的。
我想要一份由县每日切片的报告。
还有其他方法吗?
select
distinct
[MemberID]
, [AuthID]
, f.[Carrier]
, null As [County]
, [ServiceStatus]
, null As [ZipCode]
, [DischargedDate]
, f.[RequestType]
, [ProviderNPI]
, [ProviderName]
, [Discipline]
, f.[Market]
, f.[Phase]
, f.[DateValue]
, [UnitsAllowed]
, [CompletedVisits]
,COALESCE(f.[ForeCastVisits], '0') AS ForeCastVisits,f.[Is_holiday] AS IsHoliday
,f.[is_weekday] AS IsWeekday, f.[MyNexus_is_Holiday] AS MyNexusIsHoliday
,f.DaysOfTheWeek
, [ApprovedDate]
,DateFlag
into #utiltable
from #forecastValue f
left outer join #UtilizationData u
on f.datevalue=u.DailyDate
and f.market=u.market
and f.Phase=u.Phase
and f.Carrier=u.Carrier
and f.ServiceRequestType=u.ServiceRequestType
and f.county=u.county