나는 단순히 열을 더하고 싶습니다. 나는이Laravel Eloquent sum throwing error
$money = Income::select(DB::raw('sum(money)'))->get();
을 피곤이 코드
$money = Income::sum('money');
을 사용하지만 오류를 던지고. 데이터베이스로 postgresql을 사용하고 있습니다. 오류 메시지 :
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")
내 테이블 :
incomes
+----+---------+-------+
| id | orderid | money |
+----+---------+-------+
| 1 | 2343 | 23 |
| 2 | 2344 | 55 |
+----+---------+-------+
데이터베이스 스키마를 게시 할 수 있습니까? – Jaimin
@Jaimin이 (가) –
게시물을 편집했습니다. 스키마가 아니므로 게시 할 수 있습니까? 소득표를 만드는 마이그레이션 파일을 기반으로합니까? 또는 psql을 사용하여'\ d {소득 표 이름}'을 (를) 실행할 수 있고 결과를 공유 할 수 있습니까? –