功能要求如下:
-
展示user表的数据信息,要求credit>300显示优质客户,credit>200显示中等客户,credit<200显示一般客户
-
展示user表的数据信息,要求将city字段值,转换后显示,北京->首都,上海->魔都,深圳->特区,其他->省会
-
展示user表的数据信息,如果有英文名,展示其英文名;没有英文名,展示“无”
-
展示user表的数据信息,要求展示人员出生年代,比如1979年出生的,显示为“70后”;1985年出生的,显示为“80后”;1993出生的,显示为“90后”
-- 展示user表的数据信息,要求credit>300显示优质客户,credit>200显示中等客户,credit<200显示一般客户
select *,case when credit>300 then'优质客户'when credit>200 then'中等客户'when credit<200 then'一般客户' end 客户等级 from user
-- 展示user表的数据信息,要求将city字段值,转换后显示,北京->首都,上海->魔都,深圳->特区,其他->省会
select *,case city when '北京'then'首都' when'上海'then'魔都' when'深圳'then'特区' else'省会' end 城市 from user;
-- 展示user表的数据信息,如果有英文名,展示其英文名;没有英文名,展示“无”
select *,ifnull(ename,'无')英文名 from user;
-- 展示user表的数据信息,要求展示人员出生年代,比如1979年出生的,显示为“70后”;1985年出生的,显示为“80后”;1993出生的,显示为“90后”
select *,case when SUBSTRING(personID,7,3)=197 then'70后' when substring(personID,7,3)=198 then'80后' when SUBSTRING(personID,7,3)=199 then'90后' end 年代 from user;