Hello Everyone,
I am trying to get the Top 10 NPI's by State and By County based on the Current_Year_Members_Outreached. Below is the query I created but I haven't been able to verify if the results are correct because when I execute it runs and some results show but in the lower right corner of the screen it says "Formatting Page" and seems to be taking forever. My source table only has 67k records which doesn't seem like a lot. So, I have two questions:
1. Does my query below look correct based on what I am trying to achieve?
2. Is there a better way to right this query to get better performance?
As always any help is greatly appreciated....
I am trying to get the Top 10 NPI's by State and By County based on the Current_Year_Members_Outreached. Below is the query I created but I haven't been able to verify if the results are correct because when I execute it runs and some results show but in the lower right corner of the screen it says "Formatting Page" and seems to be taking forever. My source table only has 67k records which doesn't seem like a lot. So, I have two questions:
1. Does my query below look correct based on what I am trying to achieve?
2. Is there a better way to right this query to get better performance?
As always any help is greatly appreciated....
Code:
SELECT
A.STATE,
A.COUNTY,
A.NPI,
A.[SumOfCurrent Year Members Outreached]
FROM Qry_Provider_Distinct AS A
WHERE A.[SumOfCurrent Year Members Outreached] =
(
SELECT TOP 10
B.[SumOfCurrent Year Members Outreached]
FROM Qry_Provider_Distinct AS B
WHERE A.STATE = B.STATE AND A.COUNTY = B.COUNTY AND A.NPI = B.NPI
ORDER BY
B.[SumOfCurrent Year Members Outreached] DESC
)