SQL调整(优化)以使用不同的语句

时间:2018-11-19 17:50:38

标签: sql sql-server-2012 query-performance

我有一个运行非常慢的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;

0 个答案:

没有答案