hc学习平台

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

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

2021-01-06 18:02:41 查看(447) 回复(0)

完成以下功能:


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


-- 1
select card.*
from user, card
where user.name='李峰' and user.userId = card.userId;

-- 2
select user.*
from user, card
where card.cardNo=001 and user.userId = card.userId;

-- 3
select user.name,user.personId
from user,card
where card.money>10000 and user.userId = card.userId;

-- 4
select user.name,card.money
from user,card
where user.credit>400 and user.userId = card.userId;

-- 5
select city,sum(money)总金额
from user,card
where  user.userId = card.userId
GROUP BY city
ORDER BY sum(money)desc;

-- 6
select user.*
from user,card
where openDate BETWEEN '2019-01-01' and '2019-03-01' and user.userId = card.userId;

-- 7
select user.*
from user,card
where card.money>=20000 and user.city='北京' and user.userId = card.userId;

-- 8
select sex,avg(money)总金额
from user,card
where user.userId = card.userId
GROUP BY sex;

-- 9
select city,count(cardNo)
from card,user
where user.userId = card.userId
group by city;


-- 10
select name,sum(money)总金额
from user,card
where user.userId = card.userId
GROUP BY name;

-- 11
select city
from user,card
where user.userId = card.userId
GROUP BY city
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

返回顶部