vendredi 18 septembre 2020

Use field value from a subquery in another subquery where whit generate_series in PostgreSQL

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:

ERROR: missing FROM-clause entry for table "roter"

select
    (select "Account" FROM "AccountSamples" WHERE gen=gen ORDER BY random() LIMIT 1) roter,
    (select "Id" from "data" WHERE "Account" = "roter"."Account" LIMIT 1 )
from generate_series(1, 100) gen;



Aucun commentaire:

Enregistrer un commentaire