Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gA9rv-0002DU-IK for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 08:29:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gA9rt-00020L-BZ for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 08:29:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gA9rt-00020E-39 for pgsql-general@lists.postgresql.org; Wed, 10 Oct 2018 08:29:21 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gA9rq-00069R-Uw for pgsql-general@postgresql.org; Wed, 10 Oct 2018 08:29:20 +0000 Received: from [192.168.127.1] (port=25991 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1gA9ro-000IJ4-4R; Wed, 10 Oct 2018 08:29:16 +0000 Received: from [127.0.0.1] (port=41789 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1gA9rn-000Nju-A2; Wed, 10 Oct 2018 08:29:15 +0000 From: Andrew Gierth To: "David G. Johnston" Cc: Alexander Farber , pgsql-general Subject: Re: SELECT UNION into a text[] In-Reply-To: (David G. Johnston's message of "Tue, 9 Oct 2018 09:39:25 -0700") Message-ID: <87sh1e8aw4.fsf@news-spur.riddles.org.uk> References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Wed, 10 Oct 2018 09:29:14 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "David" == David G Johnston writes: >> SELECT ARRAY_AGG(hashed) >> FROM words_nouns >> WHERE added > TO_TIMESTAMP(1539100913) >> UNION >> SELECT ARRAY_AGG(hashed) >> FROM words_verbs >> WHERE added > TO_TIMESTAMP(1539100913); David> SELECT array_agg(words) FROM ( David> SELECT hashed FROM words_nouns David> UNION ALL David> SELECT hashed FROM words_verbs David> ) AS src Or even better, SELECT ARRAY(SELECT hashed FROM words_nouns UNION SELECT hashed FROM words_verbs); -- Andrew (irc:RhodiumToad)