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