改写前:

SELECT g.USER_CARDNO userCardno, p.PREMIUM

            FROM POLICIES p

            INNER JOIN gsuser g ON p.user_id = g.user_id

            INNER JOIN gsuser gs ON gs.user_account = g.user_cardno

            WHERE p.create_time >= to_date(#{treasure.startDate}, 'yyyy-mm-dd')

            AND p.create_time <= sysdate

            AND p.product_id IN (9,13,14,186,187,188,190,202,203)

            AND p.policyflag = '4'

            ORDER BY g.user_cardno,p.create_time ASC;

改写后:

SELECT g.USER_CARDNO userCardno, p.PREMIUM

            FROM POLICIES p

            INNER JOIN gsuser g ON p.user_id = g.user_id

            INNER JOIN gsuser gs ON gs.user_account = g.user_cardno

            WHERE p.create_time >= to_date('2018-01-01', 'yyyy-mm-dd')

            AND p.create_time <= sysdate

            AND EXISTS(

                select 1 from 

                (select 9 a from dual UNION all select 13 a from dual UNION all select 14 a from dual UNION all

                select 186 a from dual UNION all select 187 a from dual UNION all select 188 a from dual UNION all

                select 190 a from dual UNION all select 202 a from dual UNION all select 203 a from dual

                )where p.product_id = a

            )

            AND p.policyflag = '4'

            ORDER BY g.user_cardno,p.create_time ASC;

--------------------- 

作者:ybcljay 

 版权声明:本文为博主原创文章,转载请附上博文链接!