I have a query that outputs a list of percentages based on a total number, the only part I cant figure out is an efficient method to filter the 'usid' equal to a value on another table.
The query is not failing but is taking a very long time to complete.
SELECT badge, count(usid)*100 / (SELECT COUNT(DISTINCT usid) from Table1)
FROM Table1
WHERE usid IN(
SELECT usid
FROM Table2
WHERE msid = 1
)
GROUP BY badge
The output looks something like this
-----------------------------
badge count
-----------------------------
1 65.1
2 45.4
3 22.7
4 12.12
The usid that it is counting I am trying to set equal to the usid WHERE msid = 1. Even if this method works it takes far too long. any ideas for a work around?