我有两个名为Price和Date的列,因此我想求出价格的总和,其中月份是01:
price | date
-------------------
200 | 01-01-2022
100 | 09-01-2022
400 | 01-03-2022
120 | 01-06-2022
以下是我的代码:
$total = Products::whereMonth('date', '=', 1)->sum('price');
但它没有显示任何数据,它只显示0