hc学习平台

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

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

2021-01-07 13:49:38 查看(340) 回复(0)

完成以下功能;

  1. 查询客户的英文名,要求以小写字母显示
  2. 将客户的中文名和英文名连接成一个字符串展示
  3. 查找1992年出生的客户的交易记录信息
  4. 按姓氏统计客户信息:展示每个姓氏有多少张银行卡
  5. 查找姓名是两个汉字的客户信息
  6. 展示客户的出生日期,以【1998-02-23】格式展示


select ename ,LOWER(ename) from user

select name,ename,concat(name,',',ename) from user

-- 查找1992年出生的客户的交易记录信息

-- 找日期

select *,SUBSTRING(personId,7,4) x from user

-- 找userid

select userld from ( select *,SUBSTRING(personId,7,4) x from user) a where x=1992

-- 找cardno

select cardno from(select userld from ( select *,SUBSTRING(personId,7,4) x from user) a where x=1992) b,card where b.userld=card.userId

-- 找交易记录信息

select * from (select cardno from(select userld from ( select *,SUBSTRING(personId,7,4) x from user) a where x=1992) b,card where b.userld=card.userId) c,transinfo where c.cardno=transinfo.cardNo

-- 按姓氏统计客户信息:展示每个姓氏有多少张银行卡

select  name,count(cardno) c,userId x from card ,user where card.userId=user.userld  group by card.userId


select left(name,1),sum(c) from (select  name,count(cardno) c,userId x from card ,user where card.userId=user.userld  group by card.userId) s

group by left(name,1)

-- 查找姓名是两个汉字的客户信息

select * from user,card,transinfo where user.userld=card.userId and card.cardNo=transinfo.cardNo and name like'__';

-- 展示客户的出生日期,以【1998-02-23】格式展示

select name,concat('【',substring(personId,7,4),'-',substring(personId,11,2),'-',substring(personId,13,2),'】') x 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

返回顶部