嗨,我正在使用 eloquent 进行查询,以获取包含 100 多种产品的所有发票的 ID,这就是我正在尝试的:
$products = Product::whereRaw('sum(quantity) >= 100')->pluck('invoice_id');
我收到此错误:
Illuminate\Database\QueryException
SQLSTATE[HY000]: General error: 1111 Invalid use of group function (SQL: select `invoice_id` from `products` where sum(quantity) >= 100)
我该如何解决?