A
A
artloveyou2020-10-16 13:40:12
MySQL
artloveyou, 2020-10-16 13:40:12

How to get the sum of the values ​​produced in each row in a MYSQL query?

Let's say we have a table

price | new_price
  10       15
  20       25
  30       35


How to pull out the sum (15-10) + (25-20) + (35-30) with one request?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2020-10-16
@artloveyou

SUM()

S
Slava Rozhnev, 2020-12-28
@rozhnev

select sum(new_price - price) as total from prices;

Execute SQL query

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question