oracle nvl,having的用法

            select oi.order_id,opl.payment_no,opl.back_no, oi.commit_time, oi.receive_mobile, oi.receive_user,
              nvl((select s.code_id
                     from double_pay_check d, sys_code s
                    where d.is_delete = 'N'
                      and d.process_status = s.code_id
                      and d.order_id = oi.order_id),
                   (select s.code_id
                      from sys_code s
                     where s.code_type_no = 'double_pay_process_state'
                       and s.code_no = 'unprocess')) as process_status
              from order_payment_log opl,
                   order_info oi,
                   (select business_id
                      from (select l.business_id, l.payment_type_id, count(1)
                              from order_payment_log l
                             where l.paid_state = 'Y'
                               and l.is_delete = 'N'
                               and l.business_type = 'order'
                             group by l.business_id, l.payment_type_id
                            having count(1) > 1)) t
             where opl.business_id = t.business_id
               and oi.ORDER_ID = opl.business_id
               and oi.is_delete = 'N'
               and opl.business_type = 'order'
               and opl.paid_state = 'Y'
               and opl.is_delete = 'N'
    

 

posted @ 2017-12-25 12:27  小啊菜鸡  阅读(573)  评论(0编辑  收藏  举报