laravel 按日期分组查询
$shop_trend = ShopTrend::where($where)
->select([DB::raw('FROM_UNIXTIME(created_at,"%Y-%m-%d") as date_day'), DB::raw('SUM(month_rent) as total_rent'), DB::raw('COUNT(trend_id) as count'), DB::raw('GROUP_CONCAT(shop_id) as shop_ids')])
->groupBy('date_day')
->orderBy('date_day', 'asc')
->get();
本文介绍了如何在Laravel框架中使用SQL按日期对ShopTrend表进行分组查询,包括计算月租金总和、计数和聚合shop_id。查询结果按日期升序排列。
515

被折叠的 条评论
为什么被折叠?



