Hay un error: ERROR: column "cuidan" does not exist LINE 25: WHERE n.idnota =cuidan ^