I am trying to get monthly total sales for current year from sales table. I did something like below to get the result. But, it's returning all different month's sales sum. Would someone help me please to find out the every month's sales total from January to December for current year. I tried something like this -
$months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
$monthlySales = Sale::whereIn(DB::raw('MONTH(created_at)'), $months)
->whereYear('created_at', '=', date('Y'))
->select(DB::raw("SUM(((sellingprice * discount_percent) / 100) * productqty) as monthlySale"))
->get();
dd($monthlySales);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire