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