List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:July 23 2005 3:37am
Subject:Re: GROUP BY approximation
View as plain text  
In the last episode (Jul 22), Andy McHargue said:
> I have table with very similar values in one field,
> 
> count word
> ----- ----
> 2 APPLE
> 6 APPLES
> 1 APPEL
> 
> select *,sum(count) as total from table group by word will leave
> these rows separated.
> 
> So I want to GROUP BY that field to add the numbers (to come up with
> 9 APPLES).  Is this possible?  I guess I'm searching for some type of
> functionality similar to SOUNDEX(), except for grouping not
> selecting.

SELECT SUM(count), MIN(word), SOUNDEX(word) GROUP BY SOUNDEX(word)

If you are running mysql >= 4.1, you can use GROUP_CONCAT() to fetch
all the words matching each soundex group.

-- 
	Dan Nelson
	dnelson@stripped
Thread
Something boring about mysql application!!!song wang31 May
  • Re: Something boring about mysql application!!!Gleb Paharenko31 May
Re: Something boring about mysql application!!!mfatene31 May
  • GROUP BY approximationAndy McHargue23 Jul
    • Re: GROUP BY approximationDan Nelson23 Jul