Friend, I need advice.There are two tables/models.In one I keep a list of orders, in another I keep a list of counterparties and their commission.
id | agent_id | item | cash
1 | 1 | - | 200
2 | 2 | - | 300
3 | 2 | - | 1000
id | comission
1 | 15
2 | 20
The amount of orders grouped by agents without commission I can get,
1 | 170
2 | 1040
and how to get the total amount of orders?(1210?)
Through the request? in the model? controller? Repositories? something again just spawn...
In other words, I need to get the total amount of 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