Answer the question
In order to leave comments, you need to log in
Where to make calculations/calculations?
Others need advice.
There are two tables/models. In one, I store a list of orders, in the other, a list of counterparties and their commission.
1) orders
id| agent_id | item | cash
1 | 1 | - | 200
2 | 2 | - | 300
3 | 2 | - | 1000
2) agents
id | Commission
1 | 15
2 | 20
The amount of orders grouped by agents, excluding commission, I can get,
1 | 170
2 | 1040
but how to get the total amount of orders? (1210?)
Through request? in the model? controller? Repositories? something again just spawned ...
In other words, I need to get the total sum of the multiplication of two columns from different tables ...
UPD. something like... SELECT sum(a.cash*b.comission) FROM orders as a JOIN agents as b ON a.agent_id=b.id
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question