第九章1

--用例4
--1.修改密码
update  cardInfo set pass='123456 '--张三123456
where cardID='1010 3576 1234 5678'
update  cardInfo set pass='222222'--李四123123
where cardID='1010 3576 1212 1130'

----2.办理银行卡挂失-----------------
--描述:李四(卡号为1010357612121134)因银行卡丢失,申请挂失
update  cardInfo set IsReportLoss=1
where cardID='1010 3576 1212 1130'

--3.统计银行流通余额,盈利结算
declare @inmoney money     --声明一个总存入的变量
declare @outmoney money    --声明一个总支取的变量
select @inmoney=SUM(trademoney) from tradeInfo where tradeType='存入'
select @outmoney=SUM(trademoney) from tradeInfo where tradeType='支取'
print '银行流通余额总计为:'+convert(varchar(20),@inmoney-@outmoney)+'RMB'
print '盈利结算为:'+convert(varchar(20),@outmoney*0.008-@inmoney*0.003)+'RMB'
go

--4.查询本周开户信息
select * from cardInfo where  
DATEDIFF(weekday,opendate,GETDATE())<DATEPART(weekday,GETDATE())


--5.查询本月交易金额最多的卡号
--存入最多
select * from tradeInfo where 
tradeMoney=(select MAX(tradeMoney) from tradeInfo where 
tradeType='存入' and DATEDIFF(MONTH,tradeDate,GETDATE())<=1)


--支取最多
select * from tradeInfo where
 tradeMoney=(select MAX(tradeMoney) from tradeInfo where 
 tradeType='支取' and DATEDIFF(MONTH,tradeDate,GETDATE())<=1)


--6.查询挂失的卡号
select * from userInfo where 
customerID in(select customerID from cardInfo where IsReportLoss=1)


--7.催款提醒业务
select customername from userInfo inner join cardInfo 
on cardInfo.customerID=userInfo.customerID where balance<200

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值