完成以下功能:
-
查询【李峰】的银行卡信息
-
查询银行卡号是【001】的客户信息
-
查询存款大于10000元的客户姓名和身份证号码
-
查询信用积分大于400分的客户姓名和银行存款总额
-
查询每个城市的银行存款总额,按存款金额降序排列
-
查询在2019年1月1日至2019年3月1日期间,办理新银行卡的客户信息
-
查询银行存款大于等于20000元的北京客户信息
-
统计男客户、女客户的平均存款金额
-
统计每个城市银行卡的数量,要求不包括被冻结的银行卡
-
查询每个客户的存款总额
-
查询人均存款大于20000的城市名称
-- 查询【李峰】的银行卡信息
select * from card where userID in (select userID from user where name='李峰')
-- 查询银行卡号是【001】的客户信息
select * from user where userID in (select userID from card where cardNo='001')
-- 查询存款大于10000元的客户姓名和身份证号码
select name 客户姓名,personID 身份证号码 from user where userID in (select userID from card where money>10000);
-- 查询信用积分大于400分的客户姓名和银行存款总额
select name,sum(money) from user,card where card.userID=user.userID and credit>400 GROUP BY name
-- 查询每个城市的银行存款总额,按存款金额降序排列
select city,sum(money) from user,card where user.userID=card.userID GROUP BY city ORDER BY sum(money) desc;
-- --查询在2019年1月1日至2019年3月1日期间,办理新银行卡的客户信息
select user.* from card,user where user.userID=card.userID and openDate BETWEEN '2019-01-01'and '2019-03-01';
-- 查询银行存款大于等于20000元的北京客户信息
select user.* from user,card where user.userID=card.userID and money>='20000' and city='北京';
-- 统计男客户、女客户的平均存款金额
select sex,avg(money)from card,user where user.userID=card.userID GROUP BY sex;
-- 统计每个城市银行卡的数量,要求不包括被冻结的银行卡
select city,count(cardNo) from card,user where user.userID=card.userID and isLock=0 GROUP BY city;
-- 查询每个客户的存款总额
select name,sum(money) from user,card where user.userID=card.userID GROUP BY name
-- 查询人均存款大于10000的城市名称
select city from user,card where user.userID=card.userID GROUP BY city HAVING avg(money)>'10000';