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