名宏 鄭
名宏 鄭

Reputation: 115

How to commend addition value

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

Answers (2)

B. P. Singh
B. P. Singh

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

Kim
Kim

Reputation: 825

You can use SUM():

SELECT Name, ID, SUM(Num) AS NumTOTAL
FROM yourTable
GROUP BY Name, ID

Upvotes: 8

Related Questions