Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 06 Sep 2002 @ 14:39:50 GMT


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


Subj:   Re: Help on CASE Statement
 
From:   Arun K Ballari

Thanks every one for your help. I found an easy way to do:

select line_act_mth,

       sum(case when line_act_mth = '2'
               and cycle_mth in ('4','5','6')
               then 1
               else 0
               end ) AS FEB_KOUNT,

       sum(case when line_act_mth = '3'
               and cycle_mth in ('5','6','7')
               then 1
               else 0
               end ) AS MAR_KOUNT,

       sum(case when line_act_mth = '4'
               and cycle_mth in ('6','7','8')
               then 1
               else 0
               end ) AS APR_KOUNT

from ( select cust_id, cust_line_seq_id, extract (month from cycle_dt) AS cycle_mth1,
              extract (month from LINE_ACT_DT) AS line_act_mth1

             from SDW_PRDUSR_ALLVM.VISION_P2K_ACTS_V

             where LINE_ACT_DT between '2002-02-01' and '2002-04-30'
             and CYCLE_DT BETWEEN '2002-04-01' and '2002-08-30'
             group by 1,2,3,4) Derived(cust_id, cust_line_seq_id, cycle_mth, line_act_mth)

group by 1
order by 1

Thank you,

Arun



     
  <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