List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:March 27 2012 6:43pm
Subject:Re: Group expansion as part of the result
View as plain text  
In the last episode (Mar 27), Paul Halliday said:
> Say I have:
> 
> SELECT COUNT(name), name, COUNT(DISTINCT(status)) FROM table GROUP BY name
> 
> and it returns:
> 
> 20 paul 5
> 19 john 2
> 75 mark 3
> 
> is there a way to return what comprises  DISTINCT(status) as part of the result?
> 
> so:
> 
> 20 paul 2,3,1,20,9
> 19 john 20,9
> 75 mark 1,20,9

You want GROUP_CONCAT:

http://dev.mysql.com/doc/refman/5.5/en/group-by-functions.html#function_group-concat


-- 
	Dan Nelson
	dnelson@stripped
Thread
Group expansion as part of the resultPaul Halliday27 Mar
  • Re: Group expansion as part of the resultDan Nelson27 Mar
    • Re: Group expansion as part of the resultPaul Halliday28 Mar