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