I currently have a table with 5 differnt facilites (A,B,C, D,E). Each facility has 15 different totals. I am needing the top 10 totals for each facility in one query if possible. Any suggestions?
SELECT facilityid, facility, facilitytotal
FROM yourtablename t
WHERE facilitytotal in (
select TOP 10 facilitytotal
from yourtablename
where facility = t.facility
order by facilitytotal desc)
Thanks VJ. I tried the code you provided and received the top (max) total for each facility. This is a good start. I am just needing to get the top 10 totals for each facilty within a query (result of 50 entries instead of 5). I believe I followed your scheme correctly. My only questions was the t. that is in the where clause (t.facility). Can you enlighten me on this?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.