Archives of the TeradataForum
Message Posted: Wed, 28 Apr 2004 @ 15:14:17 GMT
Subj: | | Re: Conditional max |
|
From: | | Maxwell, Donald |
Consider your original data. The OLAP SUM function partitions by PARENT and sorts the data within each partition by AMT desc, CHILD desc. eg.
your sorted data (with the computed OLAP SUM value for each row)
PARENT CHILD AMT OLAP_SUM
X C NULL 1
X B NULL 2
X A NULL 3
Y G 40.00 1
Y F 25.00 2
Y H NULL 3
The OLAP_SUM column is the cumulative sum(1) over the sorted data within the partition, ie a running one-up counter of the sorted rows.
The QUALIFY clause behaves like a HAVING clause in that it filters rows from the result set.
Hope that helps explain.
Donald Maxwell
|