Quote:
|
Originally Posted by TokenSDragon
It's fully indexed.
More information:
The Subquery itself (the one in the where statement) takes aproximately .04 seconds to execute.
It's that stupid Count(*) statement using the subquery to feed the Where in ( ) statement that takes the massive amount of item. Which is why I'm wondering if there is another way to write this query.
It's only part of a much larger query so I'm really trying to avoid rewriting the thing into a set of a dozen small queries. That's not really an option time-wise.
So, any ideas on a faster way to get the recordcount of one query squished into a field of another? (which is basically as simple as the query gets)
|
My guess:
SELECT Evals.Patient_ID, COUNT(*)
FROM Evals INNER JOIN Patients ON Patients.Key_ID = Evals.Patient_ID
WHERE (Evals.Location_ID = 2)
AND (Patients.Center_ID = 2)
AND (Patients.Key_ID >= 820)
GROUP BY Evals.Patient_ID
HAVING (COUNT(*) > 1))
Hope this helps!
Iņaki