Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 14 Dec 2006 @ 17:26:15 GMT


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


Subj:   Re: Avoiding distinct in grouping
 
From:   Michael Larkins

You can easily do this using the COUNT aggregate and CASE, pretty much like you included in your posting:

     sel id, count( case  When dept in ('040','041') then 1 end) as group_1_txn_count
           , count( case  When dept in ('050','051') then 1 end) as group_2_txn_count
           , count( case  When dept  = '060' then 1 end )  as group_3_txn_count
     from txn_detail
     group by id

Hope this helps,

Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor



     
  <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