On Monday 02 May 2005 10:18 am, Eric Jensen wrote: > Grouping a bunch of rows together and wanting to find the average of the > count. Logic is something like "SELECT AVG(COUNT(*)) FROM table GROUP > BY field". That obviously doesn't work, anybody know a handy way to do > this? I can always loop through with my script and do the math there, > but I am curious if this can be done completely with SQL.
A subquery is helpful here: SELECT s.<whatever>,AVG(s.cnt) FROM (SELECT COUNT(*) AS cnt FROM ... GROUP BY ...) s; -- Respectfully, Nicholas Leippe Sales Team Automation, LLC 1335 West 1650 North, Suite C Springville, UT 84663 +1 801.853.4090 http://www.salesteamautomation.com .===================================. | This has been a P.L.U.G. mailing. | | Don't Fear the Penguin. | | IRC: #utah at irc.freenode.net | `==================================='
