> > But you can't get a group by from an alias.
> 
> That surprises me.  I tried putting the calculation of age in a 
> subquery but that didn't work, either.  And I've never quite 
> figured out how to create a temporary table for intermediate 
> results.  There has _got_ to be a way to do this, even an 
> awkward way.

A friend suggested the following which is rather straight forward:

  SELECT ROUND(DATEDIFF(CURDATE(), dateofbirth)/365) AS age, COUNT(1)
  FROM person GROUP BY age;


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to