I want to pull data from two columns in my database table, I'm not very good at querying SQL. When I do this query I get this error:
Expression #2 of SELECT list is not in GROUP BY clause and contains...
What am I missing?
My query:
$top_orders = OrderItem::select('name','productId', DB::raw('count(name) as total'))->groupBy('name')->orderBy('total','desc')->take(5)->get();