Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 28 Jul 2004 @ 18:05:34 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   How to make use of distinct option with count window function.
 
From:   Anomy Anom

<-- Anonymously Posted: Wednesday, July 28, 2004 14:04 -->

All,

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.

EX:

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

Thanks



     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023