名宏 鄭 名宏 鄭 - 6 months ago 10
SQL Question

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

Kim Kim
Answer

You can use SUM():

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