java – 如何对具有不同可能性的单个列的记录求和?

我有一个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+ 从这个查询我没有.全天礼物. 我有pr

我有一个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 =’半天’& present_status =我的数据库记录中的’全天’.

如何计算’全天”半天’?

最佳答案
如果您希望计数分开,则可以执行此操作

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+

关于作者: dawei

【声明】:石家庄站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐