 |
 |
Archives of the TeradataForum
Message Posted: Thu, 14 Dec 2006 @ 17:26:15 GMT
Subj: | | Re: Avoiding distinct in grouping |
|
From: | | Michael Larkins |
You can easily do this using the COUNT aggregate and CASE, pretty much like you included in your posting:
sel id, count( case When dept in ('040','041') then 1 end) as group_1_txn_count
, count( case When dept in ('050','051') then 1 end) as group_2_txn_count
, count( case When dept = '060' then 1 end ) as group_3_txn_count
from txn_detail
group by id
Hope this helps,
Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor
| |