sql查询中case when...else...end
来源:互联网 发布:接入网络方式 编辑:程序博客网 时间:2024/05/22 13:29
用于并列查询
有如下person表,查询出类型为1和2的各占多少
id type name
1 1 li
2 1 jackson
3 1 mark
4 1 didong
5 1 hanmeimei
6 2 lilei
7 2 polly
8 2 park
select count(case when t.type='1' then t.name else '' end) count1,count(case when t.type='2' then t.name else '' end) count2from person t
result:
count1 5
count2: 3
0 0
- sql查询中case when...else...end
- sql选择条件查询case when else end
- SQL SERVER中case when ... then ... else... end用法
- sql case when then else end
- Sql语句-case when then else end
- sql case when then else end
- case when。。。else。。。end
- SQL 存储中if、else判断、case...when..then..else.....end
- SQL多表查询与case when .. else .. end as ..,group by.. having
- case when then else end
- case when then else end
- case when then else end
- case+when+then+else+end
- case when then else end
- case when then else end
- case when else end用法
- CASE WHEN ELSE END 用法
- case when then else end
- 报错Error:(11) No resource identifier found for attribute 'roundIcon' in package
- Retrofit实现文件上传和下载【二】
- 股票分析技术指标概览
- 拟投会议
- 数据压缩原理与应用 DPCM编码
- sql查询中case when...else...end
- 笔记9-JAVA的初学浅识(Java的循环结构)
- logstash 清洗cdn日志的开发文件 配置
- 一周搞定MPU6050Linux驱动(3)
- css实现div旋转任意角度
- js中的继承
- 【模板】筛素数
- 万能地图下载器在地质能源应用
- nRF52832 — 修改设备ID和mac地址