# Function string\_agg() postgresql data base

**URL:** <https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397>\
**Category:** Uncategorized\
**Created:** [October 22, 2019, 7:14pm UTC](https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397 "2019-10-22T19:14:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcosgois](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@marcosgois](https://community.dremio.com/u/marcosgois)\
**Post date:** [October 22, 2019, 7:14pm UTC](https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397/1 "2019-10-22T19:14:03Z")

</div>

Hi guys !!!

Is there any alternative to using the “string\_agg” function from postgresql database in dremio?

Example below:

SELECT string\_agg(PARECER\_CONSULTOR, ’ - ')  
FROM PESQUISA.PLANO\_TRABALHO  
WHERE ID\_CONSULTOR = 7054310

---

<div class="post-metadata">

**Author:** ![deepak](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/deepak/32/1855_2.png) [@deepak](https://community.dremio.com/u/deepak)\
**Post date:** [February 15, 2020, 12:05am UTC](https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397/2 "2020-02-15T00:05:16Z")

</div>

Dremio Functions : [https://docs.dremio.com/sql-reference/sql-functions/](https://docs.dremio.com/sql-reference/sql-functions/)

Dremio has a bunch of String and Aggregation functions, does not have anything that will implement Postgress string\_agg equivalent out of the box : [https://www.postgresqltutorial.com/postgresql-aggregate-functions/postgresql-string\_agg-function/](https://www.postgresqltutorial.com/postgresql-aggregate-functions/postgresql-string_agg-function/)

---

<div class="post-metadata">

**Author:** ![munish.singla](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@munish.singla](https://community.dremio.com/u/munish.singla)\
**Post date:** [March 8, 2021, 12:26am UTC](https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397/3 "2021-03-08T00:26:13Z")

</div>

> [@marcosgois](#):
>
> string\_agg

Is there any way that a loop can create over query so multiple records can be set separated with comma?

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [March 9, 2021, 6:27am UTC](https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397/4 "2021-03-09T06:27:04Z")

</div>

@munish.singla

Currently Dremio does not support equivalent of an Oracle PL/SQL. Direct ANSI SQL is what is supported

Thanks  
Bali

---

<div class="post-metadata">

**Author:** ![munish.singla](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@munish.singla](https://community.dremio.com/u/munish.singla)\
**Post date:** [March 9, 2021, 10:10pm UTC](https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397/5 "2021-03-09T22:10:43Z")

</div>

Thanks for reply @balaji.ramaswamy  
Is there any way I can create a loop to generate that kind of required resultset?

Thanks  
Munish

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [March 10, 2021, 8:16am UTC](https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397/6 "2021-03-10T08:16:37Z")

</div>

@munish.singla

As I had mentioned, Dremio does not support loops inside the SQL construct

Thanks

---

<div class="post-metadata">

**Author:** ![donatobarone](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/donatobarone/32/4748_2.png) [@donatobarone](https://community.dremio.com/u/donatobarone)\
**Post date:** [February 8, 2023, 6:59pm UTC](https://community.dremio.com/t/function-string-agg-postgresql-data-base/4397/7 "2023-02-08T18:59:35Z")

</div>

Found a way to do this. Not sure when this functionality was released, with which version of dremio, but now you can use LIST\_AGG [Dremio](https://docs.dremio.com/software/sql-reference/sql-functions/functions/LISTAGG/), tested a couple of examples and it works like a charm.
