|
|
Archives of the TeradataForum
Message Posted: Tue, 22 Oct 2002 @ 06:12:19 GMT
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;
| |