Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tZXyU-00Ah1s-0X for pgsql-general@arkaria.postgresql.org; Sun, 19 Jan 2025 16:16:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tZXyS-008JKW-Ka for pgsql-general@arkaria.postgresql.org; Sun, 19 Jan 2025 16:16:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tZXyR-008JKO-6o for pgsql-general@lists.postgresql.org; Sun, 19 Jan 2025 16:16:32 +0000 Received: from fout-b5-smtp.messagingengine.com ([202.12.124.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tZXyN-000OSN-0H for pgsql-general@lists.postgresql.org; Sun, 19 Jan 2025 16:16:31 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfout.stl.internal (Postfix) with ESMTP id 4E5B51140161; Sun, 19 Jan 2025 11:16:25 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Sun, 19 Jan 2025 11:16:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1737303385; x=1737389785; bh=4LaNZn6+wRJoHAPwjhRQF+4ACA5PtfpE55scq9APVZo=; b= o0Pk1TppHXssIn0JXYPCT7/lhyb55pvv2WSCdG6qkcueRXAjMYmmJK7QWXLMtyWt Lt94wvWIps0egpUyrVcuSI9hRg7/vMcn+eqCyw3Tj7qlz0rm0WaQR4WWzdSjrw+9 yRJ3r15uoKiywCKfsL3DDFi8H2VweShCmyOpj5k6J6VeXcH6V5BMclbS/4juEjYz 2kB03psnC5xAq2xNYgPmaf5PKhWhClCElo9q9HGPb99WnFnPIFSxOAYISdL2LFoo nkD0lsyAmeR6JIOubSgSsvTpJp0ziR236JGkWt06WozfreVcLCcrLOnca6Lbb2xS nYvweRyj726iWPRQ+iN4VA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1737303385; x=1737389785; bh=4 LaNZn6+wRJoHAPwjhRQF+4ACA5PtfpE55scq9APVZo=; b=L1MvlgoFBmHe+vMyz 0dDFrt9AQ99Mo9ZIRNDegQ2Mbpx3+x6h2+VJdnQuzKIypIIL0f0o8eqqSaS7EIhQ MVhaDMtujCrfu32aUhw9toDoQHmD4v/1M8XpNivZ3M8+6v/VlR/+r8yg6ZwMMLwf mbkaHiBRqdipFNkL/lv9a7jzEKaMBP/u3XE+4VckBCxjmbzkX5eayoQZI9Eib/td 9Lwl9i7naFxm96ihi2Mi3D/IbLGgSxktYODX4Ms/5wUb+ZMTfPVV6LRsGOykIgF+ wjK3ONxX/32oaI7bX1z0N/hhQ8AGIV/FPZuHHgq429KZTtCJzRutM1c3wX+DTtWT 50tAQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeijedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeen ucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrse grkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeelgeevkeekkeeuiefgtdev ieeluefhfedufeetkeejffekjeeujeehgeehgeektdenucffohhmrghinhepphhoshhtgh hrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspg hrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsghrvghnthdr fihoohgusehnihifrgdrtghordhniidprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrg hlsehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 19 Jan 2025 11:16:24 -0500 (EST) Message-ID: <53b84a62-5aa7-4cd6-bb81-ef79bc8f93af@aklaver.com> Date: Sun, 19 Jan 2025 08:16:23 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: concatenating hstores in a group by? To: Brent Wood , "pgsql-general@lists.postgresql.org" References: <2268303.1737134384@sss.pgh.pa.us> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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, >               > 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