Try those analytical functions provided by oracle.
[url]http://www.dbasupport.com/forums/showthread.php?threadid=7586[/url]

Sam