I've got a MySQL statement that selects a name and also makes a ranking.
SELECT t.name,
(SELECT COUNT(*)
FROM my_table1 z
WHERE z.type LIKE '%Blue%'
AND t.type LIKE '%Blue%'
AND (z.score1+ z.score2 + z.score3 + z.score4) >= (t.score1+ t.score2 + t.score3 + t.score4)) AS rank
FROM my_table1 t, my_table2 d
WHERE d.name = t.name
AND t.status != 'unknown'
AND t.type = 'Blue'
AND d.area_served = '$area_id'
ORDER BY rank ASC
But, I also need to know out of how many the rank is calculated. So for example, ranked #4 out of X.
How do I count the total number of rows in the ranking sub-query? I need the count for this bit:
(SELECT COUNT(*)
FROM my_table1 z
WHERE z.type LIKE '%Blue%' AND t.type LIKE '%Blue%'
AND (z.score1+ z.score2 + z.score3 + z.score4) >= (t.score1+ t.score2 + t.score3 + t.score4)) AS rank
Thank you.
-Laxmidi