【发布时间】:2020-08-24 23:28:43
【问题描述】:
我是 laravel 的新手,所以我对同一张表中两列的总和有一点问题。
对于列 sum(dug) 和列 sum(pot),我的回答应该是两位十进制数。这些列之间的加减法和其他操作无关紧要。我只想要 sum(dug) 和 sum(pot)...
我的代码是:
public function getBalance() {
$details = AnalyticalCard::select('sum(dug) as duguje, sum(pot) as potrazuje')
->where('firma', 001)
->where('komitent', 'V003')
->where('konto', 2020)
->get();
return response()->json($details);
}
我的 SQL 查询是:
select
sum(dug) as duguje, sum(pot) as potrazuje
from
fn_promet
where
firma = 001 and komitent = 'V003' and konto = '2020'
【问题讨论】: