Reputation: 115
I have a table and this table have three column like this
--------------
|Name|ID |Num|
--------------
|A |001|1 |
|A |001|2 |
|A |001|3 |
--------------
I want show NAME ID and total of Num like the anwser
NAME ID NumTOTAL
A 001 6
Upvotes: 0
Views: 50
Reputation: 13
Its very easy after using sum() function of sql
select name,id sum(num) as [Total Num] from tableName Group by name,id
Upvotes: 1
Reputation: 825
You can use SUM()
:
SELECT Name, ID, SUM(Num) AS NumTOTAL
FROM yourTable
GROUP BY Name, ID
Upvotes: 8