sql - 使用 Distinct 的语句的 SQL 调优(优化)
问题描述
我有一个运行速度非常慢的 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;
解决方案
推荐阅读
- php - 如何在 Smarty 上创建插件?
- html - 相对创建的按钮和图像会导致为图像创建额外的框架。html
- javascript - 如何使用在其类上创建的方法将从类创建的对象添加到数组
- docker - docker 无法在带有 dind 的容器中启动。启动守护程序时出错:找到 pid 文件,确保 docker 未运行或删除 /var/run/docker.pid
- rspec-rails - Guard 不执行 capybara 测试的规范/功能
- abcpdf - ABCpdf PdfConformityOperation.GetData PDFException
- sql - SPSS Modeler SQL 查询 CASE 语句链接到 Excel 文件
- vue.js - 如何处理我的 vue 组件中更改的任何数据?
- python - Owlready2 优化不可用
- java - 在 android 中过滤掉来自 OEM 的不需要的系统应用程序