MS ACCESS Subselect "At Most one record can be returned by this subquery."

Asked

Viewed 11 times

0

Would someone know to tell me the pq of this subselect is causing the error: "At Most one record can be returned by this subquery."?

(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) AS historicoStatus" 

1 answer

0


Fixed by adding 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" 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.