Archives of the TeradataForum
Message Posted: Fri, 30 Jul 2004 @ 07:29:30 GMT
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.
|Copyright 2016 - All Rights Reserved|
|Last Modified: 23 Jun 2019|