-1

With this data:

name movie
john big daddy
bob titanic
john avatar

I want the output to be:

name movie
john big daddy, avatar
bob titanic

tried this:

SELECT name, LIST_AGG(movie)
from people.table 
group by name;

but getting an error:

Function list_AGG(varchar) does not exist, or permission is denied for list_AGG(varchar).

4
  • Have you tried anything? Commented May 21 at 9:23
  • 1
    yes, ARRAY_AGG or LISTAGG functions and getting a permission error: Function list_AGG(varchar) does not exist, or permission is denied for list_AGG(varchar). Commented May 21 at 9:37
  • 1
    Please edit your attempt and the error into your question. Commented May 21 at 9:39
  • 1
    Docs say LISTAGG not LIST_AGG docs.vertica.com/11.1.x/en/sql-reference/functions/… Commented May 21 at 10:33

1 Answer 1

1

Vetica has STRING_AGG() function - try it like this:

WITH     --  S a m p l e    D a t a :
  tbl AS
    ( Select 'john' as a_name, 'big daddy' as a_movie Union All
      Select 'bob', 'titanic' Union All
      Select 'john', 'avatar'
    )
--      S Q L : 
Select    a_name, STRING_AGG(a_movie, ',') as movies
from      tbl
Group By  a_name; 

Result:

a_name movies
bob titanic
john big daddy,avatar

fiddle

Sign up to request clarification or add additional context in comments.

2 Comments

still getting same error :/
@yesiamamir Then, at least, you can exclude "function does not exist" part of the error message which left you with "permission is denied" part. We know nothing about that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.