sql 统计查询某一字段的某一个值的总条数 您所在的位置:网站首页 sql查询某一列数据的个数 sql 统计查询某一字段的某一个值的总条数

sql 统计查询某一字段的某一个值的总条数

2024-06-30 19:12| 来源: 网络整理| 查看: 265

查询某一字段的某一个值的总条数

比如:orderprogressno字段的值分别为1,2,3,4,那么就是查询值为1的总条数和值为2的总条数

select orderno,count(orderprogressno)from servicerepair 已阅读  = sum(case when orderprogressno =1 then 1 else 0 end), 未阅读  = sum(case when orderprogressno =2 then 1 else 0 end), from servicerepair

select orderno , sum(case when orderprogressno =1 then 1 else 0 end),as yiyuedu sum(case when orderprogressno =1 then 1 else 0 end),as weiyuedu from servicerepair group by orderno

mybatis下代码:

select count (case when orderprogressno =1 then 1 else null end) 已阅读, count (case when orderprogressno =2 then 1 else null end) 已联系, count (case when orderprogressno =3 then 1 else null end) 已预约, count (case when orderprogressno =4 then 1 else null end) 正在服务, count (case when orderprogressno =5 then 1 else null end) 已经完成, count (case when orderprogressno =6 then 1 else null end) 已经结束, count (case when orderprogressno =7 then 1 else null end ) 已经取消 from servicerepair where deptno =#{deptno}

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有