如何分别查找具有相同值的列的多列总和?

时间:2019-02-15 06:55:56

标签: mysql database laravel eloquent

我有一个包含// parent include this method handleSetData = (myData) => { this.setState({ myData: myData }); } // inside render and your child component pass the method to it <ChildComponent setData = {this.handleSetData} /> // Child Component, inside your button <Text onPress={('Some data') => this.props.setData('Some data'})}></Text> invoice_id quantity的表,现在我需要分别用相同的{{1}找到ratequantity的总和}。

rate

这仅显示一个字段的结果,

1 个答案:

答案 0 :(得分:0)

您可以找到多个列的总和,如下所示:

 $invoices_quantity = Sale::select(
                           DB::raw('sum(quantity) as quantity_count'),
                           DB::raw('sum('rate') as rate_count')
                       ->groupBy('invoice_id')
                       ->get();