hc学习平台

 找回密码
 立即注册
搜索
热搜: 活动 交友 javakc
 › javav › 日志

逻辑函数:根据教材中的user表、card表、transInfo表进行查询

2021-01-07 12:37:18 查看(533) 回复(0)

功能要求如下:

  1. 展示user表的数据信息,要求credit>300显示优质客户,credit>200显示中等客户,credit<200显示一般客户
  2. 展示user表的数据信息,要求将city字段值,转换后显示,北京->首都,上海->魔都,深圳->特区,其他->省会
  3. 展示user表的数据信息,如果有英文名,展示其英文名;没有英文名,展示“无”
  4. 展示user表的数据信息,要求展示人员出生年代,比如1979年出生的,显示为“70后”;1985年出生的,显示为“80后”;1993出生的,显示为“90后”

-- 1.展示user表的数据信息,要求credit>300显示优质客户,credit>200显示中等客户,credit<200显示一般客户
select *,(case when credit>300 then '优质客户' when credit>200 then '中等客户' else '一般客户' end)客户等级
from user

-- 2. 展示user表的数据信息,要求将city字段值,转换后显示,北京->首都,上海->魔都,深圳->特区,其他->省会
select *,(case city when '北京' then '首都' when '上海' then '魔都' when '深圳' then '特区'  else '省会' end)外号
from user

-- 3. 展示user表的数据信息,如果有英文名,展示其英文名;没有英文名,展示“无”
select *,ifnull(ename,'无')英文名 from user

-- 4. 展示user表的数据信息,要求展示人员出生年代,比如1979年出生的,显示为“70后”;1985年出生的,显示为“80后”;1993出生的,显示为“90后”
select name,substring(personId,7,4)出生,(case  when substring(personId,9,2)<80 then '70后'  when substring(personId,9,2)<90 then '80后' when substring(personId,9,2)<100 then '90后' else '太老了' end)年代
from user

评论 (0 个评论)

facelist

全部作者的其他最新日志



站点统计|举报|Archiver|手机版|小黑屋|Comsenz Inc.

GMT+8, , Processed in 0.195171 second(s), 9 queries .

Powered by javakc! X1.0

© 2004-2014 javakc

f1208.com 备案号:京ICP备14030918号-1

返回顶部