Laravel Group By Date

后端 未结 2 445
囚心锁ツ
囚心锁ツ 2021-01-16 08:13

I am trying to make an elqouent query for a following sql,

select sum(w.total_item_count) as Day_count, w.created_at as created_at from `sales_flat_orders`          


        
2条回答
  •  梦毁少年i
    2021-01-16 08:39

    $orderbydate = DB::table('sales_flat_orders as w')
                    ->select(array(DB::Raw('sum(w.total_item_count) as 
                    Day_count'),DB::Raw('DATE(w.created_at) as created_at')))
                    ->orderBy('w.created_at')
                    ->get();
    
    
    $orderbydate->groupBy('w.created_at');
    

提交回复
热议问题