From the top of my head the only way I can think of doing what you want is to use PL SQL function without defining aggregate function. There is a hack published by @Marty Zigman back in 2015 that can help you with that, this hack uses OVER(PARTITION_BY).