I have this query to show a list of trending (most searched) names on my website:
SELECT name, COUNT(*) AS total_trends
FROM trending_names
WHERE dateTime BETWEEN '"&fromDate&"' AND '"&toDate&"' // -7 days to Now()
GROUP BY name
ORDER BY COUNT(*) DESC
LIMIT 10;
...and this is the kind of results I'm printing to screen: (numbers represent quantity of searches made)
Angelina Jolie 31,293
Rihanna 26,722
Lindsay Lohan 18,351
Brad Pitt 11,901
I would now like to change the numbers to percentages; so I really need to be getting the total count of all trending names within the last 7 days, to calculate the correct percentage.
Is there a way I can add a total count to this query, without adding an additional query?