Skip to content

Is it possible to SELECT into list? #3797

Answered by lnkuiper
Admolly asked this question in Q&A
Discussion options

You must be logged in to vote

I believe you are looking for the list aggregate function:

D create table tbl (col varchar);
D insert into tbl values ('a'), ('b'), ('c'), ('c');
D select 'col' as column, list(col) as values from tbl;
┌────────┬──────────────┐
│ column │    values    │
├────────┼──────────────┤
│ col    │ [a, b, c, c] │
└────────┴──────────────┘
D select 'col' as column, list(distinct col) as values from tbl;
┌────────┬───────────┐
│ column │  values   │
├────────┼───────────┤
│ col    │ [a, b, c] │
└────────┴───────────┘

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Admolly
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants