From: Claire Lee [mailto:[EMAIL PROTECTED]

> I have a table like this
> 
> name   price   type
> A        10      1
> B        30      2
> A        20      1
> B        20      2
> 
> would like to distinct based on name and type, do a
> sum and get the following result
> 
> name   price  type
> A       30      1
> B       50      2  
> 
> How do I do this with one sql query? Thanks.


SELECT name, SUM(price), type FROM tablename GROUP BY name, type;


-- 
Mike Johnson
Web Developer
Smarter Living, Inc.
phone (617) 886-5539

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

Reply via email to