Archives of the TeradataForum
Message Posted: Wed, 28 Jul 2004 @ 18:05:34 GMT
<-- Anonymously Posted: Wednesday, July 28, 2004 14:04 -->
How do I make use of distinct option with Count window function. Basically I need to count the distinct values at different levels/groups with 1 SQL.
sel div, cd1, typ , count(id) over (partition by div, typ rows between unbounded preceding and unbounded following) as lvltyp , count(id) over (partition by div, typ , cd1 rows between unbounded preceding and unbounded following) as lvlcd from t1;
In the above query, I would like to have distinct values for column ID . As distinct option is not allowed with OVER clause , is there any way to do this.
I want accomplish this using only 1 SQL. ( No unions...etc)
Values in the table.:
div cd1 typ id mnt bn bo loco 1234 100 bn Lo loco 1234 200
Result I would like to see is
div cd1 typ lvltyp lvlcd bn bo loco 1 1 bn Lo loco 1 1
|Copyright 2016 - All Rights Reserved|
|Last Modified: 28 Jun 2020|