--Pass each of the pmi value from the below query to an outer query.
select pmi
from support
where supportid = (select supportid
from support
where pmi = '123'
order by datereceived DESC
fetch first 1 row only)
and reason ='XYZ'
I have multiple rows for a particular pmi in my table support.
For each set of pmi, I need to find the latest row using the datereceived column, and then check whether that latest row has a reason 'XYZ'.
Only if the reason is 'XYZ' in the latest row, I have to pass the pmi value to an outer query.
It works if I hard code a pmi into the inner query, but I want the inner query to iterate over all the pmi in the table.
Any help would be appreciated.