0
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

Edited by GeoEqual: format error

2
Contributors
2
Replies
19
Views
4 Years
Discussion Span
Last Post by GeoEqual
0

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

Edited by IIM

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.