Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 30 Jul 2004 @ 07:29:30 GMT


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


Subj:   Re: How to make use of distinct option with count window function.
 
From:   Victor Sokovin

  Good place for a derived table:  


I would even use two derived tables in this case because one table does not seem to be doing what the OP requested, even not in the example that he/she provided.

The easiest query I could think of might look something like this:

     sel A.div, A.cd1, A.typ, A.lvlcd, B.lvltyp
     from ( sel div, cd1, typ, count(distinct id) lvlcd
     from t1
     group by 1,2,3  ) A,
     ( sel div, typ, count(distinct id) lvltyp
     from t1
     group by 1,2 ) B
     where A.div=B.div
     and A.typ=B.typ ;

If this type of SQL is acceptable to the OP then I don't see any reason to use the window form of COUNT.


Regards,

Victor



     
  <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