laravel - How to get Total Sum of one column after multipling with other column values
问题描述
take a look at this Database screenshot
There are two different columns, i want to multiply column "Purchase" value with Column "Stock". and then want to Sum of all answers. As per example, first row answer is 6600 and second row answer is 4500, i want total after multiplication and sum.
Tried this code: but getting 0 as result.
$purchase_sum = Stock::All()->sum('purchase' * 'stock');
Using Laravel eloquent method.
Thanks in advance
解决方案
推荐阅读
- javascript - 使用来自 Django 的 JsonResponse 更新 DataTable 无法正常工作
- shell - 不要在抽屉中显示标题 FlyoutItem 外壳 - xamarin 表单
- javascript - 如何等待构造函数完成?
- javascript - 为什么方法中未定义对象数据?
- javascript - 来自外部文件的 JavaScript 调用函数给出 .is not a fuction 错误,我该如何解决?
- nativescript - 错误:在非 ES5 类上调用 getInternalNameOfClass():预期 RadListViewComponent 具有内部类声明
- json - 如何使用 jq 从 json 中输出所有键和值?
- python - 如何创建仍然将垃圾收集到范围之外的循环引用?
- kubernetes - 使用 Persistent Volume Claim 时是否必须显式创建 Persistent Volume?
- python - Python BeautifulSoup 循环遍历 div 和多个元素