|
|
Archives of the TeradataForum
Message Posted: Wed, 28 Apr 2004 @ 17:51:30 GMT
Subj: | | Re: Conditional max |
|
From: | | Hough, David A |
I think the solution by Donald Maxwell:
SELECT
,PARENT
,CHILD
,AMT
FROM SomeTable
QUALIFY SUM(1) OVER ( PARTITION BY PARENT
ORDER BY AMT desc, CHILD desc ROWS UNBOUNDED PRECEDING ) = 1;
Can be improved somewhat by replacing SUM with RANK:
SELECT
PARENT
,CHILD
,AMT
FROM SomeTable
QUALIFY RANK() OVER ( PARTITION BY PARENT
ORDER BY AMT desc, CHILD desc) = 1;
Not that I would have found his original on my own... ;)
/dave hough
| |