Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Add ARRAY(SELECT) example to the arrays file #4

Closed
polobo opened this issue Aug 24, 2017 · 1 comment
Closed

Add ARRAY(SELECT) example to the arrays file #4

polobo opened this issue Aug 24, 2017 · 1 comment

Comments

@polobo
Copy link

polobo commented Aug 24, 2017

SELECT ARRAY(SELECT col1 FROM ( VALUES (1), (2), (3) ) vals (v)); -- {1,2,3}

basically equivalent to SELECT (SELECT array_agg(col1) ...)

I'm not sure whether one performs better than the other but the ARRAY() form seems more natural when working in a scalar subquery context.

@kmoppel
Copy link
Contributor

kmoppel commented Sep 11, 2017

Added with minor corrections. Feel free to do a PR when not exactly what you meant:)

-- using the ARRAY constructor
SELECT ARRAY(VALUES (1), (2), (3));
-- ARRAY constructor with a subselect
SELECT ARRAY(SELECT v FROM ( VALUES (1), (2), (3) ) vals (v));

@kmoppel kmoppel closed this as completed Sep 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants