I'm just simply want to sum column . I used this code
$money = Income::sum('money');
also tired this
$money = Income::select(DB::raw('sum(money)'))->get();
but it's throwing error . I'm using postgresql as my database . Error message :
SQLSTATE[42883]: Undefined function: 7 ERROR: function sum(character varying) does not exist
LINE 1: select sum("money") as aggregate from "incomes"
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts. (SQL: select sum("money") as aggregate from "incomes")
my table :
incomes
+----+---------+-------+
| id | orderid | money |
+----+---------+-------+
| 1 | 2343 | 23 |
| 2 | 2344 | 55 |
+----+---------+-------+