A table where X, Y and Z have some individual amounts.
Sample data:
Name | Amount | Date
—————|————————|—————————
X | 100 | 15-11-17
Y | 50 | 15-11-17
X | 50 | 15-11-17
Z | 70 | 15-11-17
Z | 30 | 15-11-17
Now I want to show a table where X will return one row with the summation of it's two values in the same date.
Expected result:
Name | Amount | Date
—————|————————|—————————
X | 150 | 15-11-17
Y | 50 | 15-11-17
Z | 100 | 15-11-17
So what is the laravel query for that? I use groupBy(). But can't get the targeted result.
Here is my laravel query code
$data = DB::table('transactions')
->select('transactions.*')
->groupBy('transactions.title_id')
->whereDate('transactions.created_at', '=', $date)
->get();
And got this error continuously
"SQLSTATE[42000]: Syntax error or access violation: 1055 'finance_report.transactions.id' isn't in GROUP BY
Anybody please help