我想知道如何计算总行数,同时计算总量?
这是我的代码
$total_sales = $this->db->table('order_payment')
->selectRaw('*, sum(order_payment.amount) as total_amount, order_header.*')
->leftjoin('order_header', 'order_header.order_id', '=', 'order_payment.order_id')
->where(DB::raw('Date(reference_date)'), $sales_date)
->where('order_header.order_type_id', '2')
->get();
我目前得到的总金额,我能得到的是order_type_id
行的总数..
答案 0 :(得分:0)
你能改变吗?
sum(order_payment.amount) as total_amount, ...
到
sum(order_payment.amount) as total_amount, sum(order_type_id) as total_order_type_id, ...