fb_pixel

Where to make calculations / calculations?

Development | Web Development
Description
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.

1) orders
id | agent_id | item | cash
1 | 1 | - | 200
2 | 2 | - | 300
3 | 2 | - | 1000
2) agents
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
Attachments
No attachments
Info
Description
All the calculations that can be made a request, it is better to make a request.A DB will almost always make calculations faster.
on March 18th, 2020 (2:56 pm)
All coments
This job has not been commented yet.