Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 22 Oct 2002 @ 06:12:19 GMT


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


Subj:   Re: Distinct Count with case statement
 
From:   Arndt, Ulrich

Your SQL should work.

Try Code below.

Ulrich


create table test
( k integer,
  i integer,
  a char(1),
  b char(1),
  c char(1)
) unique primary index (k);

insert into test values (1,1,'a',NULL,Null);
insert into test values (2,1,'b',NULL,Null);
insert into test values (3,2,NULL,'a','b');
insert into test values (4,2,NULL,'a','b');
insert into test values (5,2,NULL,'b','c');
insert into test values (6,2,NULL,'b','c');
insert into test values (7,2,NULL,'d','f');

select i, count(distinct case when i = 1 then a else b||c end)
from test
group by 1
;

drop table test;


     
  <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