oracle基础案例(1)

select * from o_mdm_ac_rel   --账号与客户介质表
select * from o_dd_mst       --活期存款主文件
select * from o_trace_log    --业务流水
(一个账户存在多个账号,一个客户存在一个账号信息)
--1.交易流水中找出账户为101214673的卡号交易用子查询的方式

select * from o_trace_log where ac_id=101214673;

select * from o_trace_log where ac_no in
 (select ac_no from o_mdm_ac_rel where ac_id=101214673)

--2.在活期账户主文件中找出徐耀华的账户用exists实现
select d.* from o_dd_mst d where exists
   (select * from o_mdm_ac_rel m where m.name='徐耀华' and d.ac_id=m.ac_id)

--3.当天没有进行交易,且账户余额超过1000元的账户有多少人?用not exists实现
select  count(*) from o_dd_mst m where not exists
  (select  ac_id from o_trace_log t where t.ac_id=m.ac_id  )
and bal>1000
 
--4.开户日期最早的第5人到第10人的数据
select s.* from 
 (select rownum rn,e.* from
 (select d.* from o_dd_mst d where length(opn_date)=8 order by d.opn_date) e)s
where rn between 5 and 10;

--5.找出交易流水中名字长度大于4位的数据
select * from o_trace_log where length(name)>4;


--6.查询过程中,把前三位为承德市的数据替换为河北省承德市,只能用函数实现。

select replace(name,'承德市','河北省承德市'),concat('河北省',name)
from o_mdm_ac_rel  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值