Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 05 Sep 2002 @ 15:31:39 GMT


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


Subj:   Help on CASE Statement
 
From:   Arun K Ballari

Gurus,

please help me write the CASE Statement in Teradata. Essentially what I am looking is to count the distinct no.of bills for each month. Any help will be greatly appreciated.


Thanks,

Arun K Ballari,

select   CAST(( LINE_ACT_DT (format 'mmmb,byyyy')) AS CHAR(12)),

                (case when LINE_ACT_DT between '2002-02-01' and '2002-02-28'
                        and CYCLE_DT BETWEEN '2002-04-01' and '2002-06-30'
                        then    count(distinct(cust_id || cust_line_seq_id || extract (month from cycle_dt)))
                        else 0
                        end ) AS FEB_KOUNT,

                (case when LINE_ACT_DT between '2002-03-01' and '2002-03-31'
                        and CYCLE_DT BETWEEN '2002-05-01' and '2002-07-31'
                        then    count(distinct(cust_id || cust_line_seq_id || extract (month from cycle_dt)))
                        else 0
                        end ) AS MAR_KOUNT,

                (case when LINE_ACT_DT between '2002-04-01' and '2002-04-30'
                        and CYCLE_DT BETWEEN '2002-06-01' and '2002-08-30'
                        then    count(distinct(cust_id || cust_line_seq_id || extract (month from cycle_dt)))
                        else 0
                        end ) AS APR_KOUNT

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
order by 1


     
  <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