Joining table onto itself

Posts   
 
    
rell
User
Posts: 25
Joined: 15-Apr-2009
# Posted on: 01-Jul-2009 07:23:15   

Hi

I have to convert the following Oracle statement into LLBLGen. Can you please help as I can't find anything in the forum that talks about joining a table onto itself.

    SELECT 'CHANGED' AS movement_status, count(*)
          FROM slim.detailed_inventory di1, slim.detailed_inventory di2
         WHERE di1.slot_sun = di2.slot_sun
           AND TO_DATE ('01/04/2008', 'dd/mm/yyyy') 
           bETWEEN di1.date_fr AND NVL (di1.date_to,SYSDATE + 1)
           AND TO_DATE ('30/06/2009 ', 'dd/mm/yyyy') 
           BETWEEN di2.date_fr AND NVL (di2.date_to,SYSDATE + 1 )
           AND (di1.nmi in (select nmi from slim.nmi_allocation 
           where contest_fl='Y' and euc_cd ='BCC') 
           AND di2.nmi in (select nmi from slim.nmi_allocation 
           where contest_fl='Y' and euc_cd ='BCC'))
           AND (   di1.euc_cd <> di2.euc_cd
                OR di1.nmi <> di2.nmi
                OR di1.dev_type_id <> di2.dev_type_id
                OR di1.sl_rate_cd <> di2.sl_rate_cd
                OR di1.control_usage_type_id <> di2.control_usage_type_id
               )  ;

Thanks in advance

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Jul-2009 09:54:22