here is my table in database:

name     qty     unitcost     totalcost
A        1       10           10
A        3       10           30
B        2       20           40
B        1       20           20

here is what i want to view to user:

name     qty     unitcost     totalcost
A        4       10           40
B        3       20           60

use distinct keyword t get distinct name.SUM() function to return total sum of a numeric column where name is same,i.e done by using groupby clause.

SELECT DISTINCT name, sum( qty ) , unticost, sum( totalcost )
FROM `table1` 
GROUP BY name

thanks a lot, u helped me a lot