PortfolioNumber LevelCode AccountNumber Status track
123 2 A101 Failed 1
123 2 A102 Failed 1
123 2 A103 Passed 0
123 1 A101 Passed 0
123 1 A102 Passed 0
123 1 A103 Passed 0
123 3 A101 Failed 1
123 3 A102 Failed 1
123 3 A103 Failed 1
456 1 A406 Failed 1
456 1 A407 Passed 0
456 1 A408 Failed 1
I have got this table by doing certain other join to other few tables,
What this table data denotes to - Portflio Number (123) is there and we have in total three AccountNumber. We have different LevelCode (here 1,2,3) and each level is tagged to portfolioNumber and will have same 3 accountnumber tagged too. and We also have status at each row...Have created track Column jsut to have Failed as 1 and Passed as 0 which I tried using later in My below query (This column can be deleted)
What I am trying to find -
Lowest level code set per unique Portfolio Number(which Comprises of all three accountsNumber for that set ) where either of Status is failed
Query - Select PortfolioNumber, LevelCode, min(LevelCode), sum(track) from (table data which I got via some other tables join..pasted above) group by PortfolioNumber, LevelCode having sum(track) > 0'
But this does not give the correct result and all columns, running out of options now
Desired Result What I am
PortfolioNumber LevelCode AccountNumber Status track
123 2 A101 Failed 1
123 2 A102 Failed 1
123 2 A103 Passed 0
456 1 A406 Failed 1
456 1 A407 Passed 0
456 1 A408 Failed 1
Using Oracle