Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 03 Feb 2004 @ 12:38:46 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Query Performance
 
From:   Henry Runn

Hi

try this one:

select sd.branch_id, b.branch_name, sd.date_loaded,
sum(sd.sales_amount) as sales, sum(sd.cost_amount) as cost
from
(select branch_id, date_loaded,sim_mfr_no,sim_item_no,
sum(sales_amount) as sales_amount, sum(cost_amount) as cost_amount
from sales_detail
where date_loaded between '2003/03/01' and '2003/06/01'
and ((je_prime_no = '007' AND je_sub_no IN ('01', '02'))
OR (je_prime_no = '006' AND je_sub_no = '01' AND acct_prime_no = ' ')
OR (je_prime_no = '006' AND je_sub_no = '01' AND acct_prime_no > '0' AND
sales_amount = 0.0)
OR (je_prime_no = '006' AND je_sub_no = '01' AND acct_prime_no = '222'
and acct_sub_no in ('05','11','12') AND adder_code = '1')
OR (sd.branch_id in (7302,7304,7305) and je_prime_no = '006' AND
je_sub_no = '01'
AND acct_prime_no = '201' and acct_sub_no = '02'))
group by branch_id, date_loaded,sim_mfr_no,sim_item_no) sd,
mw_panduit_id p, branch b

where sd.sim_mfr_no = p.sim_mfr_no
and sd.sim_item_no = p.sim_item_no
and sd.branch_id = b.branch_id
group by 1,2,3
order by 1,2,3


     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016