I need select an group iformation from these, but a have some conditions:
- Group results by date (day). Ideally when day start on 09.00 and finsh 09.00 (24hr)
- Then i need summarize values field
sum
where'satus_id'
= 10 into new variable example'TotalIn'
and wherestatus_id
= 12 into variable exampleTotalOut
- Give results on view (but this no problem)
How to do it? I write this, but i now this is wrong:
$statistic = DB::connection('mysql2')->table('payout_transactions')
->selectRaw('*, DATE(date) as day')
->where('status_id', 12)
->selectRaw('SUM(sum) AS TotalIn')
->groupBy('day')
->get();
via Taras Bezdushnuy