title: Use field value from a subquery in another subquery where whit generate_series in PostgreSQL
body: <p>I need to select and Id from the data table, but where the Account is equal to the Account selected by the first subquery. Is that possible? I'm using generate_series because I need to populate a table with random data and I tried the query below but I get the error:</p>
  <blockquote>
  <p>ERROR:  missing FROM-clause entry for table &quot;roter&quot;</p>
  </blockquote>
  <pre><code>select
      (select &quot;Account&quot; FROM &quot;AccountSamples&quot; WHERE gen=gen ORDER BY random() LIMIT 1) roter,
      (select &quot;Id&quot; from &quot;data&quot; WHERE &quot;Account&quot; = &quot;roter&quot;.&quot;Account&quot; LIMIT 1 )
  from generate_series(1, 100) gen;
  </code></pre>