SQL Server 基础:Case两种用法
2016-03-11 09:27
525 查看
测试数据
1).等值判断->相当于switch case
2)条件判断->相当于if else if else
1).等值判断->相当于switch case
select S#,C#,C#=( case C# when 1 then '语文' when 2 then '数学' when 3 then '英语' when 4 then '选修' end ) from Sc
2)条件判断->相当于if else if else
select S#,score,score=( case when score<60 then '差' when score between 60 and 80 then '中' when score between 80 and 90 then '良' when score between 90 and 100 then '优' else '缺考' end ) from Sc
相关文章推荐
- MySQL 安装
- Mongodb - TTL(time to live)特性
- oracle 如何获取年、月、日列表
- Oracle 树操作(select…start with…connect by…prior)
- SQL Server开启远程访问设置
- 大话数据库SQL注入的N种姿势
- Mysql双机热备实现
- SQL Server 基础:Join用法
- MySQL总结
- 嵌入式SQL
- 【Oracle】【FAQ】Oracle SQL Developer 编辑区不能删除,后退,空格,复制粘贴等功能都失效的解决办法
- 数据库的连接
- MySQL查询
- 如何创建数据库及表和外键
- SQL Server安全(1/11):SQL Server安全概述
- MongoDB驱动之Linq操作
- mysql日期类型默认值'0000-00-00'容错处理
- MYSQL添加新用户 MYSQL为用户创建数据库 MYSQL为新用户分配权限 (二)
- MYSQL添加新用户 MYSQL为用户创建数据库 MYSQL为新用户分配权限 (二)
- MYSQL添加新用户 MYSQL为用户创建数据库 MYSQL为新用户分配权限