我有一个运行非常慢的SQL语句,我想知道是否有更好的方法编写它。也许使用WHERE EXISTS代替DISTINCT?我不确定谢谢。
SELECT distinct
b.ClientID,
b.FillDate as 'Fill_Date',
b.MEDNbr as 'MED'
FROM
[MedDB].[dbo].[Claim] b
LEFT JOIN [MedDB].[dbo].[Store] c
on b.StoreID = c.StoreID
LEFT JOIN [MedDB].[dbo].[StoreGroup] d
on c.StoreGroupID = d.StoreGroupID
left join [MedDB].dbo.[carrier] e
on b.carrierId = e.carrierId
left outer join [MedDB].dbo.[CarrierGroupCarrier] f
on b.carrierID = f.carrierId
left join [MedDB].dbo.[CarrierGroup] g
on f.CarrierGroupId = g.CarrierGroupId
WHERE
b.MEDNbr = 1
and b.CloseDate is NULL
and b. OpenClaimAmt Not In (0, -0.07, -0.10, 0.03, 0.05, 0.06, 0.12, 0.13, 0.26) )x;