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