FareedR
1 month ago
415
2
Laravel

using groupBy on whereColumn()

Posted 1 month ago by FareedR

how can i groupBy using whereColumn() ?

$profit_stocks = Stock::where(function($q){
	$q->whereColumn('profit','>','loss')->orderBy('profit','desc');
})->groupBy('signal')->get();

// database
id | profit | loss | signal |
1	4		2	ABC
2	4		3	ABC
// expected result 
ABC

Please sign in or create an account to participate in this conversation.