I
I
Ibishka2020-07-22 19:56:58
SQL
Ibishka, 2020-07-22 19:56:58

How to calculate the sum of all products?

SELECT g.id, g.title, g.price * b.quantity AS price, i.img, c.color, s.size, b.quantity FROM basket b
      JOIN goods g ON g.id = b.goods_id
      JOIN images i ON i.goods_id = g.id
      JOIN colors c ON c.id = b.color_id
      JOIN sizes s ON s.id = b.size_id

So I take a list of products. How to calculate the sum of all products, make a separate request to the database and take it from there or use JS to summarize from the array of products?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-07-22
@tsklab

Cumulative totals .
Running total in SQL .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question