laravel5.5 用一条sql统计count(*)价格和订单数

例如:

$order = DB::table('third_orders')->select(DB::raw('count(*) as count_order, sum(order_price) as count_price'))

    ->where(['third_key' => $third_key])->get()->sum('order_price');


或者:

$order = DB::table('third_orders')->where(['third_key' => $third_key])->count();//总订单数

//  $price = DB::table('third_orders')->where(['third_key' => $third_key])->sum("order_price");//总价格

你可能感兴趣的:(laravel5.5 用一条sql统计count(*)价格和订单数)