wtorek, 19 lipca 2011

  1. Make sure that there are no duplicates!!!
    select distinct tc.COMPANY_ID, tc.NAME from 
           TAB_TACC_RECHNUNGEN tr,  
           tab_tacc_company tc 
    where tr.COMPANY_ID = tc.COMPANY_ID and 
           UPPER(tc.NAME) like UPPER('%scc%') 
    group by tc.COMPANY_ID, tc.NAME 
    order by tc.NAME
    
    
    tab_tacc_technungen is needed because we need only companies with invoices - but why join and not exist?
    Why distinct and group by?
    tc.company_id is PK of tab_tacc_company - so after elimination of 'join', distinct is not needed any more.

Brak komentarzy:

Prześlij komentarz