让我们说我有以下表格:
ID, Name ,insurance , per_diem, net_salary, rr, rent, other_allowances
1, John 1000 0 2000 0 0 0
2, Jim 1000 0 2000 0 0 0
3, Steve 500 0 3000 0 0 0
4, Tom 0 0 0 0 0 0
我运行以下查询
SELECT Sum((((((applicant.insurance + applicant.per_diem) +
applicant.net_salary) + applicant.rr) + applicant.rent) +
applicant.other_allowances)) As available_fund
WHERE applicant.id = id;
From applicant
我希望得到每个人的总和
有可能吗?
答案 0 :(得分:0)
你必须先使用然后使用
SELECT Sum(applicant.insurance + applicant.per_diem +
applicant.net_salary + applicant.rr + applicant.rent +
applicant.other_allowances) As available_fund
From applicant
group by applicant.id
它将为所有员工提供总和,但如果您想获得一些微粒员工,那么请where
条件
WHERE applicant.id = id