|
|
Archives of the TeradataForum
Message Posted: Fri, 30 Jul 2004 @ 07:29:30 GMT
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
| |