我有一个 mysql 查询:
SELECT count(*) as `present_days`
FROM tbl_intime_status
WHERE employee_status = 'Out' and
present_status = 'Full Day' and
date LIKE '%/"+month2+"/"+year1+"' and
employee_id="+ EmpId+
从这个查询我得到没有。 全天
出席。
我的数据库记录中有 present_status= 'Half Day'
& present_status = 'Full Day'
。
如何计算“全天”+“半天”?
最佳答案
如果你想把计数分开,你可以这样做
SELECT present_status, count(*) as `present_days`
FROM tbl_intime_status
WHERE employee_status = 'Out' and
present_status IN ('Full Day','Half Day')
date LIKE '%/"+month2+"/"+year1+"' and
employee_id="+ EmpId+
GROUP BY present_status
如果你想要两者的总和,那么就这样做
SELECT count(*) as `present_days`
FROM tbl_intime_status
WHERE employee_status = 'Out' and
present_status IN ('Full Day','Half Day')
date LIKE '%/"+month2+"/"+year1+"' and
employee_id="+ EmpId+
关于java - 如何对具有不同可能性的单个列的记录求和?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12137205/