Mysql 数据库case when then else end语句用法
来源:互联网 发布:枚举 c语言 编辑:程序博客网 时间:2024/05/16 15:27
SELECT case when sex='1' then '男' when sex='2' then '女' else 0 end from test
上面语句意思:test表中如果sex=’1’,则返回值’男’如果sex=’2’,则返回值’女’ 否则返回‘0’结束
再举个例子 统计年龄指定范围内的人数
大于20小于30
大于30小于50
select sum(case when age > 20 and age < 30then 1 else 0 end) as "num",sum(case when age > 30 and age < 50then 1 else 0end) as "num",form test;
阅读全文
0 0
- Mysql 数据库case when then else end语句用法
- mysql case when then else end 用法
- MySQL case when then else end 用法
- MySQL case when then else end 用法
- MySQL case when then else end 用法
- MySQL数据库:case when then else end
- case when then...else end sql 语句用法
- SQL的case when then else end语句的用法
- [MySQL学习笔记]case when then else end用法
- MySql 中 case when then else end 的用法
- MySql 中 case when then else end 的用法
- MySql 中 case when then else end 的用法
- MySql 中 case when then else end 的用法
- MySql-中-case-when-then-else-end-的用法
- MySql 中 case when then else end 的用法
- Sql语句-case when then else end
- case,when,then,else,end的mysql语句用法与说明
- MySql 中 case when then else end 条件控制语句的用法
- C#命名空间
- django 第一个demo网站
- HDU 1584 蜘蛛牌 搜索 回溯
- 链表中头指针和头节点(头结点)
- Kanzi学习之路(7):kanzi的资源预加载
- Mysql 数据库case when then else end语句用法
- python2和3兼容问题
- 测试程序
- BZOJ3450 Easy-概率与期望-递推
- MySQL 学习<六> 查询语句
- 《Python数据分析与展示》学习笔记(一)numpy数据存储与函数
- yarn resourceManager 找不到nodeManager
- Nginx+Tomcat+Redis (负载均衡+session共享)完整案例
- 文档