Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 22 Oct 2002 @ 00:35:12 GMT


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


Subj:   Distinct Count with case statement
 
From:   Dev a p

Hi,

I have a question. Appereciate your help. SQL needs distinct count with different column as per case statement conditions.

Table data :
Source   Col1 Col2 Col3
Plant1    x1
Plant1    x2
Plant2          x1   y1
Plant2          x1   y1
Plant2          x2   y2

SQL ????????
Select Source ,
distinct count ( Case When Source = 'Plant1' Then Col1
When Source = 'Plant2' Then (Col2 || col3) End )

Result should be :
Source Count
Plant1  2
Plant2  2

Could you please help me to put the sql code.

Thanks,



     
  <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