|
|
Archives of the TeradataForum
Message Posted: Fri, 05 Jan 2007 @ 16:35:39 GMT
Subj: | | Re: Counting a column multiple times based on CASE |
|
From: | | Syed, Nizam |
Looks fairly easier.
sel id
,sum(Case When frst_prch_days between 0 and 90
Then 1
Else 0 end
)As txns_1
,sum(case when frst_prch_days between 91 and 365
then 1
else 0
end) as txns_2
,sum(case when frst_prch_days between 366 and 548
then 1
else 0
end) as txns_3
,sum(case when frst_prch_days ge 549
then 1
else 0
end) as txns_4
from temp3
group by 1
Thanks
| |