I am trying to get the min and max values for an attribute and display the id associated with each value and write SQL for this. Specifically I need to Identify the highest and lowest performers for each of 33 quality measures from the Medicare shared savings program 2013 Quality results. The table for the 2013 Quality results has the first column as the ACO name, then values in 33 columns to the right with that ACOs numeric grade for ACO-1 to ACO-33 (as the metrics of quality). There are 221 ACO names or records each with 33 grades.
Here is the SQL I used but the results show the first row as the lowest performing ACO and the second Column is the highest performer for that ACO. How can I alter the query to answer the question and pull the highest ACo and Lowest ACO for each of the 33 ACO quality metrics into a single result set?
SELECT ACO_Name, Max(Aco_1) AS Max_ACO_1, Min(Aco_1) AS MIN_ACO_1
WHERE ACO_1 = (Select Max(Aco_1) From MEd_shared_savings) or
ACO_1 = (Select Min(Aco_1) From MEd_shared_savings)
GROUP BY Aco_name;
This is the result set that shows the correct data but it is supposed to be in 1 row. Please advise as to what to do in SQL and MS Access.
ACO_Name Max_ACO_1 MIN_ACO_1
Essential Care Partners II, LLC. 66.89 66.89
Genesis Accountable Care Organization, LLC 89.71 89.71