加入收藏 | 设为首页 | 会员中心 | 我要投稿 51站长网 (https://www.51zhanzhang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
站内搜索:
当前位置: 首页 > 站长学院 > MySql教程 > 正文

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

发布时间:2021-04-02 04:41:52 所属栏目:MySql教程 来源:网络整理
导读:我有一个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+

(编辑:ASP站长)

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

    相关内容
    未处理完善
      无相关信息
    未处理完善