Fixed by adding to PK in order by.
(SELECT TOP 1 J.observacao " +
" FROM tblPendenciaHistorico J " +
" INNER JOIN tblPendenciaPendenciaHistorico JH " +
" ON J.historicoId = JH.pendenciaHistoricoId " +
" WHERE JH.pendenciaId = P.pendenciaId " +
" ORDER BY J.data DESC, J.historicoId DESC) AS historicoStatus"