Home > Archive > MySQL ODBC Connector > April 2005 > how to use row total in aggregate query ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to use row total in aggregate query ?
Graham Anderson

2005-04-27, 1:23 pm

I have a query:
I am trying to get a percentage of the total for each city

SELECT userLog.city,userLog.region,
COUNT(*),

/*
Count(userLog.id) is always 1
was hoping to get the total row returned
*/
COUNT(*)/COUNT(userLog.id),

media.name,artist.name
FROM userLog,media,artist

WHERE userLog.media_id=media.id
And userLog.city != ''
AND media.artist_id = artist.id
GROUP BY userLog.city

I was hoping Count(userLog.id) would give me the total number of
returned rows in the query...so I could return a percentage of the
total

what would be the correct syntax to include the row total ?



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com