假设现在有张账户申请表t_fund_apply,表里有个字段fund_code账户类型。每个账户类型有对应的t_fund_price表。
现在针对对t_fund_apply表,是根据客户不同的选择产生对应的记录,后台再根据apply进行相应的处理。
目前的需求是针对apply表,必须是所有的账户类型都要有t_fund_price记录才允许做。
如果有a , b两个账户,但是只有a账户有t_fund_price,b账户没有。此时无需找出对应的apply记录。
请大神们帮忙设计一下这个sql
t_fund_trans_apply表的数据
select *
from t_fund_trans_apply t
where t.policy_id = 367167
and t.apply_time = date '2016-04-11'
有3条数据:
1 5496334 11 4/11/2016
2 5496335 12 4/11/2016
3 5496336 13 4/11/2016
select t.fund_code, t.pricing_date, t.price_status
from t_fund_price t
where t.fund_code in (11, 12, 13)
and t.pricing_date = date '2016-04-11';
有两条数据:
1 11 4/11/2016 3
2 12 4/11/2016 3
这种由于t_fund_price表没有符合条件的fund_code为13的数据,
所以不应该把t_fund_trans_apply的记录查询出来。
只有t_fund_price中所有fund_code都存在的情况下,需要把t_fund_trans_apply的记录查询出来。