sql中case when then简单用法
来源:互联网 发布:android耗电量优化 编辑:程序博客网 时间:2024/05/17 23:33
如想统计一栋楼里边各学历的分布情况,即各学历有多少人,degree是学历。下图为数据库:
①普通的写法是
select degree, count(degree) dnumfrom t_residentwhere build_id=1 group by degree;结果为:
②但若要求得到学历的详细信息,上图就显得不那么直观。可以使用case when then end写法来转化数据库中的信息。
select (casewhen degree=1 then '高中以下'when degree=2 then '高中'when degree=3 then '大专'when degree=4 then '本科'when degree=5 then '硕士'when degree=6 then '博士'else '博士以上'end)lable,degree, count(degree) dnumfrom t_residentwhere build_id=1 group by degree;结果为:
这样效果会更好些。
- sql中case when then简单用法
- sql 中case when then else的简单用法
- sql 中case when then else的简单用法
- SQL中CASE WHEN THEN的简单用法
- SQL case when then end 简单用法
- SQL中case when then用法
- SQL中CASE WHEN THEN的用法
- SQL中case when then 用法
- SQL中case when then用法
- sql中case when then
- SQL中 case when then end的用法
- SQL SERVER中case when ... then ... else... end用法
- SQL中case,when,then,end的用法(…
- SQL之case when then用法详解
- sql case when then end 用法
- SQL之case when then用法
- sql case when then end 用法
- SQL之case when then用法
- hdu3696Farm Game(SPFA求最长路)
- 在项目中,main文件中都做了一些什么呢
- 数塔--poj3176
- 端口号的作用及常见端口号用途说明
- rmxp4droid 2.4最终版(20131003)
- sql中case when then简单用法
- OCP-1Z0-052-V8.02-20题
- java的23种设计模式
- hdu 4465 Candy(概率公式+极大乘极小,4级)
- silverlight右下角定时弹窗,模拟信息报警
- sizeof,终极无惑(上)
- 10种排序算法总结
- win7 64位 wamp安装memcache
- C tips