功能要求如下:
-- 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