here is what the data look like:
i am trying to select any occurence of an acctnbr which has a fund that is different from the other funds for that acctnbr. In the above data it would be the acctnbr 000002 and fund 5656.
My query seems to get in a loop. what's wrong with it? any suggestions?
select a.acctnbr, a.fund
from tb945 a
where exists (select 1 from tb945 x
where a.acctnbr = x.acctnbr
and a.fund <> x.fund)
define "last" occurrence -- there is no sequence column here
thanks for your response, r937.
I have re-phrased my question. i am looking for any occurence of acctnbr whose fund is different from the other funds for that acctnbr. In the data above, it would be that very last row. does this make sense?
HAVING COUNT(DISTINCT fund) > 1
Thank you, R937! I just need to ask one more thing..
How can I select the acctnbr and the different funds for the result table? In this case, I would like to see 000002, 3434, 5656 printed in the result table. How can I do that?