加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

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

发布时间:2021-04-03 13:29:48 所属栏目:编程 来源:网络整理
导读:我有一个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+ 从这个查询我没有.全天礼物. 我有pres

我有一个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+

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读