Hello all,
I am trying to use STRING_AGG on my sql query but getting the attached error.
I don't understand why this function doesn't exist as it the most common way to aggregate strings in sql.
If there is other method I am missing, any help will be appreciated.
Regards,
Michael

I am not sure of the context but STRING_AGG takes 2 parameters. The first is the table column name such as "Roles" or {tablename}.roles. The second is a string/char delimiter such as "," or ";". So my function would look something like this... STRING_AGG( table-name.column-name, ';' ). Good luck...
@Stanley_Stancavage my function is written just fine, the error I am presenting says that it doesn't take STRING_AGG at all.. there is no syntax issue here but something else that I am trying to understand
No the error is saying it can not find a function with a matching signature to the one you supplied.
given signature
Name: STRING_AGG
Parameter Count: 2
Parameter 1 Type: String
Paramter 2 Type: unknown
expected/known signature
Name: STRING_AGG
Parameter Count: 2
Parameter 1 Type: String
Paramter 2 Type: String
if you fix the 2nd parameter so it isn't evaluating as unknown
your problem should go away
my guess, you might be reading in a null
value in the table and trying to use it as the 2nd parameter to STRING_AGG
1 Like
I can't edit the post after it's marked, but figured it was worth a reply to mention what makes up a function signature and what it is:
- The signature is used to match the function you call with the proper block of code. The need for this becomes apparent when you start overloading functions (more than 1 function with the same name but different parameters and/or return types). Sometimes you overload functions you create, like having
sum(val1, val2) return int
and sum(val1, val2, val3) return int
, and othertimes you overload built-in functions, usually this involves something like Array.prototype
but it depends on the language (sometimes you can overload operators, like +
or *
to define new functionality)
Function signatures have 4 parts:
- function name
- number of parameters
- parameter types
- return type
if any 1 of these differ from another previous declaration a new function signature is created, resulting in the above scenario.