hc学习平台

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

根据教材中的user表和card表进行多表查询

2021-01-06 19:13:59 查看(337) 回复(0)

完成以下功能:


  1. 查询【李峰】的银行卡信息
  2. 查询银行卡号是【001】的客户信息
  3. 查询存款大于10000元的客户姓名和身份证号码
  4. 查询信用积分大于400分的客户姓名和银行存款总额
  5. 查询每个城市的银行存款总额,按存款金额降序排列
  6. 查询在2019年1月1日至2019年3月1日期间,办理新银行卡的客户信息
  7. 查询银行存款大于等于20000元的北京客户信息
  8. 统计男客户、女客户的平均存款金额
  9. 统计每个城市银行卡的数量,要求不包括被冻结的银行卡
  10. 查询每个客户的存款总额
  11. 查询人均存款大于20000的城市名称


select * from card where userId=(select  userld from user where name='李峰');

select * from user where userld=(select userId from card where cardNo='001');

select name, personId from user where userld in (select userld from card where money>10000);

select  user.name,card.money,user.credit from user,card  where user.userld=card.userId

having  credit>400;

select city, sum(money)from card ,user  where user.userld=card.userId

group by city desc;

select * from user where userld in(select userld from card where openDate between '2019-1-1' and '2019-3-1');

select * from user where userld in(select userld from card where money>20000) and city='北京';

select sex, avg(money)from card ,user  where user.userld=card.userId

group by sex desc;

select city, count(city)from card ,user  where user.userld=card.userId and card.isLock=0

group by city;

select name,sum(money)from card ,user  where user.userld=card.userId

group by name desc;


select city,avg(money)from card ,user  where user.userld=card.userId

group by city desc

HAVING avg(money)>10000;

评论 (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

返回顶部