Eloquent and tables 3 tables
Cash_payment, local_payment, online_payment.
I have daily total price calculated for each table.
.my question is its possible to sum total price of 3 tables.
Each table as no relationship and no common table b/c in case of changing value can cause problem .
I think it's clear :)
I would just run a query for each and sum them afterwards.
I cannot see any way to do it in a single query that would effective
I agree w/ Sinnbeck. You could do it all in one query if you wanted to do some subselects. Depending on how often this is used/calculated you may want to consider a SQL view or even a nightly job to do the calculation into a warehouse and then pull your daily off that. It all depends on your final objective.
Can you show me with some code please ....I am lost
Step by step
Calculation take place every day for all customers
Run ->sum() on each table and the add the results.
https://laravel.com/docs/5.8/queries#aggregates
To restrict to a date you can use $q->whereDate('created_at', '=', Carbon::today()->toDateString());
Sorry I am currently on mobile so I am having a hard time formatting properly 😊
I run sum query for each table and how can I sum the 3 daily price from 3 tables... for specific customer_id, date
Please sign in or create an account to participate in this conversation.