Re: concatenating hstores in a group by?

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: concatenating hstores in a group by?
Дата
Msg-id 53b84a62-5aa7-4cd6-bb81-ef79bc8f93af@aklaver.com
обсуждение исходный текст
Ответ на concatenating hstores in a group by?  (Brent Wood <Brent.Wood@niwa.co.nz>)
Список pgsql-general
On 1/17/25 12:43, Brent Wood wrote:
> Hi,
> 
> I have a table with a timestamp and hstore columns with times in 
> milliseconds.
> 
> I want to concatenate the hstores, grouped by timestamp, with the 
> timestamps truncated to whole seconds: date_trunc('seconds', timer).
> 
> How can I concatenate all the hstores within a one second interval,
> 
>   ie, something like:
> 
> select timer,
>                <hstores concatenated>
> from (select  date_trunc('seconds', timer) as timer_sec, hstore)
> group by timer;

1) This is going to need some example data and the table definition.

2) The above query does not make sense.

3) Hstore does not store duplicate key values:

 From here:

https://www.postgresql.org/docs/current/hstore.html#HSTORE-OPS-FUNCS

select 'a=>b, c=>d'::hstore || 'c=>x, d=>q'::hstore ;
            ?column?
------------------------------
  "a"=>"b", "c"=>"x", "d"=>"q"

Are there duplicated keys and if so how do you want to handle them?


> 
> 
> Thanks
> 
> 
> Brent Wood
> 
> Principal Technician, Fisheries
> NIWA
> DDI:  +64 (4) 3860529
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




В списке pgsql-general по дате отправления: