hc学习平台

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

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

2021-01-07 14:32:47 查看(250) 回复(0)

功能要求如下:

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

select * ,(CASE 
WHEN credit>300 THEN
'优质客户'
WHEN credit>200 THEN
'中等客户'
WHEN credit<200 THEN
'一般客户'
end
)from user


select userId,name,ename,personId,sex,credit ,(CASE 
city WHEN '北京' THEN
'首都'
WHEN '上海' THEN
  '魔都'
WHEN city='深圳' THEN
  '特区'
end
)city from user


SELECT ename ,if(ename='','无',ename)ename from user


select userId,name,ename,personId,sex,credit ,(CASE 
 WHEN substring(personId,7,4)>'1969' and substring(personId,7,4)<'1980'  THEN
      '70后'
WHEN substring(personId,7,4)>'1979'  and substring(personId,7,4)<'1990'THEN
  '80后'
WHEN substring(personId,7,4)>'1989'  and substring(personId,7,4)<'2000'THEN
  '90后'
end
)year 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

返回顶部