Home > Software engineering >  Search by amount laravel
Search by amount laravel

Time:11-03

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)

CodePudding user response:

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)
  • Related