A表中的数据根据条件,不能再B表中存在,显示A表符合条件的数据

该代码来自某QQ
只能借鉴,类似需求可以使用

select c.*
from (
    select 
        p2p_funds_details.id_,
        p2p_funds_details.fund_id_,
        p2p_funds_details.cur_stage_no_,
        b.profit_plan_,
        b.period_length_,
        b.period_unit_
    from 
        p2p_funds_details ,
        p2p_plan_bids
    where 
        p2p_funds_details.plan_bid_id_ = p2p_plan_bids.id_
        and p2p_funds_details.insert_date = '2018-10-10'
        and p2p_funds_details.status_ in (0,2)
        and p2p_funds_details.cur_stage_no_


    ) c
    left join
    (
        select 
            p.fund_id as fid,
            max(p.cur_stage_no_) as cur_stage_no_2,
        from 
            p2p_funds_details p,
            p2p_plan_bids b
        where 
            p.plan_bid_id = b.id_
        group by p.fund_id_ 
    ) t on (c.fund_id = t.fid)
where c.cur_stage_no_ != t.cur_stage_no_2;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值