D
D
Dmitry2017-09-21 11:05:54
MySQL
Dmitry, 2017-09-21 11:05:54

How to do sum MYSQL values?

Hello!
There is a table:

id      | field_id |   val
7823 |	446 |	2	
7823 |	446 |	-1	
7823 |	446 |	-1	
7824 |	446 |	1	
7824 |	446 |	-1	
7824 |	446 |	3	
7825 |	446 |	-1	
7825 |	446 |	-1	
7825 |	446 |	3

How can I make a sql query to get:
7823 |	446 |	0	
7824 |	446 |	3	
7825 |	446 |	1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-09-21
@muldy

SELECT ...., SUM(val) FROM ... GROUP BY id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question