Reputation: 113
I want to make a query in Laravel using ORM and return the result in JSON.
SELECT * FROM `reviews`
GROUP BY `school_fk` HAVING (SUM(re_count) > 4)
I tried more ways but it didn't work for me although I run it in MySQL. This was the last trial for me:
Reviews::groupBy('school_fk')->havingRaw('sum(re_count)>', 2)->get();
error : Argument 2 passed to Illuminate\Database\Query\Builder::havingRaw() must be of the type array, integer given
Can anyone help?
Upvotes: 0
Views: 44
Reputation: 29413
Put all your having
part inside the first parameter of the function. As of now you're splitting it into two parts.
Reviews::groupBy('school_fk')->havingRaw('sum(re_count) > 2')->get();
Upvotes: 1