Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Suppose I have one table like

tableA
----------------------------
Nam Amount
---------------------------
Admin 200
Smith 300
Admin 400
Smith 100
Admin 200

I want to show this table like
tableA
----------------------------
Nam Amount
---------------------------
Admin 800
Smith 400

NB: all are MSSQL tables

Thanks in advance
Posted
Updated 28-Dec-10 23:21pm
v3

You need to group by name, and select on name and the sum of amount.
This is easily googleable by the way:
http://www.google.com/search?q=group+by+with+sum&sourceid=ie7&rls=com.microsoft:en-gb:IE-SearchBox&ie=&oe=[^]
 
Share this answer
 
Homework?
Any way, here goes the answer:
SQL
SELECT [Name],SUM(Amount) 
FROM tableA
Group By [Name]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900