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