Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 22 Aug 2008 @ 10:28:00 GMT


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


Subj:   Re: How Can I Avoid Repeating an Expression?
 
From:   Baker, Andy

Name the expression

     sel substr(date,1,7) Yr_Month,
             Svc_Ownr_Cd,
             Bucket,
             case
               when cl_amt = 0 and curr_bal > cl_amt then '(0)  CL=0 & Bal>CL'
               when curr_bal <= cl_amt                     then '(1)  not OL'
               else case
                      when ((100 * (curr_bal - cl_amt) / cl_amt) (named clpct))
                                      <= 10 then      '(2)  <= 10%'
                      when clpct <= 15 then     '(3)  <= 15%'
                      when clpct <= 20 then     '(4)  <= 20%'
                      when clpct <= 25 then     '(5)  <= 25%'
                      else                               '(6)  > 25%'
                    end
             end as OL_Pct,
             count(1) Number
         from  Table
         where ...
         group by 1,2,3,4

Regards

Andy Baker



     
  <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: 15 Jun 2023