We can use SUM(), AVG(), COUNT(), etc. in GROUP clause. These are all
numeric functions. Is it possible to use string functions as well? I
know MIN() & MAX() can be asciibetical for string fields, but wouldn't
this be very handy/practical?

SELECT division,
       G_CONCAT(", ",first_name) as nicks,
       COUNT(*) as num_nicks
FROM employees
GROUP BY division;

will return:

division   nicks                       num_nicks
--------   -----                       ---------
sales      John, David, Billy          3
accounting David, Mickey               2
techsupp   Alice, Bob, Dennis, John    4
r&d        Lisa                        1
test                                   0

Other aggregate string functions might be G_MD5(), G_MAKE_SET(),
G_SPAM_RATING() :-)

Aggregate functions for sets might also be nifty to have sometimes.

--
dave


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



Reply via email to