Archives of the TeradataForum
Message Posted: Fri, 05 Jan 2007 @ 16:12:43 GMT
Your problem here is that the count function will count all non-null values. So when a case condition is not true, the 0 is returned and counted.
So, if you change the false condition to be a null, those rows are not counted.
Hope this helps,
select id ,count(Case When frst_prch_days between 0 and 90 Then trxn_id Else null end )As txns_1 ,count(case when frst_prch_days between 91 and 365 then trxn_id else null end) as txns_2 ,count(case when frst_prch_days between 366 and 548 then trxn_id else null end) as txns_3 ,count(case when frst_prch_days ge 549 then trxn_id else null end) as txns_4 from temp3 group by 1
|Copyright 2016 - All Rights Reserved|
|Last Modified: 27 Dec 2016|