I have a requirement in a Query. The Original query is somewhat like this: Select A.col1, A.col2, B.col1, B.col2, C.col1. C.col2, C.col3 ,D.Col1, D.col2 ., ., ., From A Left Outer Join B on (A.col1 = B.col1) Left Outer Join C on (A.col1 = B.col1) left outer join D on (C.col2 = D.col1) left outer join E on (D.col1 = E.col1) left outer join F on (E.col1 =F.col1) . .. so on where some filter condition.. now i have to add two subqueries in the query above. Logic of 1st Subquery is ( if B.col3=C.col3 then C.col3 else max(C.col3)) Logic for Second Subquery is (If B.col3 = (If D.col3 = 'A' then E.col3 else if D.col3='B' then F.col3) then B.col3 ) Else Max ((If D.col3 = 'A' then E.col3 else if D.col3='B' then F.col3) ) How to incorporate these Sub-queries into the Whole Above Query. I have incorporated the logic thru Two Simple Straightforward Case Statements in the Main Select Query itself with other columns which is working in oracle and but not working in the reporting tool where the query needs to be used so now it needs to be done using sub-queries as that's work in the reporting tool too.