Alex
Alex

Reputation: 53

Search by amount laravel

How can I find a record by the sum of the field values ?

I tried it like this, but there is no result

->where(DB::raw('sum(two_place,ona_place)'), '>', 5)

Upvotes: 0

Views: 31

Answers (1)

mrhn
mrhn

Reputation: 18926

Sum() is an aggregate function, that will be used in context of grouping data. you should add the columns together instead.

->where(DB::raw('two_place + ona_place'), '>', 5)

Upvotes: 3

Related Questions