# STUFF or STRING\_AGG function alternative in Dremio to grouping fields?

**URL:** https://community.dremio.com/t/stuff-or-string-agg-function-alternative-in-dremio-to-grouping-fields/5561
**Category:** Uncategorized
**Created:** [May 15, 2020, 6:39pm UTC](https://community.dremio.com/t/stuff-or-string-agg-function-alternative-in-dremio-to-grouping-fields/5561 "2020-05-15T18:39:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![stanley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/stanley/32/2506_2.png) [@stanley](https://community.dremio.com/u/stanley)
#### Post date: [May 15, 2020, 6:39pm UTC](https://community.dremio.com/t/stuff-or-string-agg-function-alternative-in-dremio-to-grouping-fields/5561/1 "2020-05-15T18:39:00Z")

</div>

How can create a query to grouping fields ?

Like STUFF or STRING\_AGG functions

```auto
SELECT id,
    STUFF (
        (SELECT   
                ',' +name  
        FROM temp1
        FOR XML PATH('')), 1, 1, ''
    ) as Name
FROM temp1 GROUP BY id

or

SELECT id,
    STRING_AGG (name , ',') AS Name
FROM temp1 GROUP BY id

Output:
-----------------------------------
| id | Name |
|---------------------------------|
| 1 | aaa,bbb,ccc,ddd,eee |
-----------------------------------

```
