Ahh, light dawns!!!
Thanks guys, much appreciated!!! (as always)
Brent
On Saturday, March 13, 2021, 3:52:33 AM GMT+13, Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
"David G. Johnston" <david.g.johnston@xxxxxxxxx> writes:
> On Fri, Mar 12, 2021 at 3:18 AM Brent Wood <Brent.Wood@xxxxxxxxxx> wrote:
>> Is this what you mean?
>>
>> select measurement_key,
>> value
>> from t_reading_hstore,
>> lateral ((EACH(value)).key as measurement_key,
>> lateral ((EACH(value)).value as value;
> The definition of "each" shows that it returns a record type. That whole
> type can be considered a table and referenced in the select list.
Yeah. To my mind, the main point here is to run each() just once per
t_reading_hstore row, not twice. So something like
SELECT e.key, e.value FROM t_reading_hstore AS t, each(t.value) AS e;
(Writing LATERAL is optional.)
regards, tom lane
> On Fri, Mar 12, 2021 at 3:18 AM Brent Wood <Brent.Wood@xxxxxxxxxx> wrote:
>> Is this what you mean?
>>
>> select measurement_key,
>> value
>> from t_reading_hstore,
>> lateral ((EACH(value)).key as measurement_key,
>> lateral ((EACH(value)).value as value;
> The definition of "each" shows that it returns a record type. That whole
> type can be considered a table and referenced in the select list.
Yeah. To my mind, the main point here is to run each() just once per
t_reading_hstore row, not twice. So something like
SELECT e.key, e.value FROM t_reading_hstore AS t, each(t.value) AS e;
(Writing LATERAL is optional.)
regards, tom lane