# Data Explorer Query - add additional parameter in export

**URL:** https://meta.discourse.org/t/data-explorer-query-add-additional-parameter-in-export/151899
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [May 19, 2020, 3:43am UTC](https://meta.discourse.org/t/data-explorer-query-add-additional-parameter-in-export/151899 "2020-05-19T03:43:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [May 19, 2020, 3:43am UTC](https://meta.discourse.org/t/data-explorer-query-add-additional-parameter-in-export/151899/1 "2020-05-19T03:43:52Z")

</div>

I want to have my list of “Users\_Who\_Replied\_To\_A\_Topic” Include the user’s NAME.

I tried to follow a convention from another thread, which makes these [Data Explorer](https://meta.discourse.org/t/32566?silent=true) queries include additional information but it didn’t work when I applied the same syntax.

Here’s the query I’m running right now, which only returns they “username” of those who replied to a topic…

> ```
> -- https://meta.discourse.org/t/68756/8?u=sidv
> 
> -- [params]
> -- topic_id :topic_id = 536
> 
> SELECT u.username
> FROM badge_posts p
> JOIN topics t ON p.topic_id = t.id 
> JOIN users u ON p.user_id = u.id
> WHERE t.id = :topic_id
> GROUP BY p.user_id,u.username
> 
> ```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 19, 2020, 12:02pm UTC](https://meta.discourse.org/t/data-explorer-query-add-additional-parameter-in-export/151899/2 "2020-05-19T12:02:32Z")

</div>

Add

```
 , u.name

```

After u.username in the first line.

---

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [May 19, 2020, 3:26pm UTC](https://meta.discourse.org/t/data-explorer-query-add-additional-parameter-in-export/151899/3 "2020-05-19T15:26:36Z")

</div>

Thanks for the quick help on this, Jay! I updated to the following, per your suggestion:

> ```
> SELECT u.username, u.name
> FROM badge_posts p
> JOIN topics t ON p.topic_id = t.id 
> JOIN users u ON p.user_id = u.id
> WHERE t.id = :topic_id
> GROUP BY p.user_id,u.username
> 
> ```

… then got this error…

> ```
> PG::GroupingError: ERROR: column "u.name" must appear in the GROUP BY clause or be used in an aggregate function
> LINE 12: SELECT u.username, u.name
> 
> ```

So I changed the query to the following and it worked like a charm! 🎉

> ```
> SELECT u.username, u.name
> FROM badge_posts p
> JOIN topics t ON p.topic_id = t.id 
> JOIN users u ON p.user_id = u.id
> WHERE t.id = :topic_id
> GROUP BY p.user_id,u.username,u.name
> 
> ```

So from my original snippet, I added the following:

To the “SELECT” line:  
`, u.name`

To the “GROUP BY” line:  
`,u.name`

Thanks again, @pfaffman for helping me with this syntax!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 19, 2020, 3:28pm UTC](https://meta.discourse.org/t/data-explorer-query-add-additional-parameter-in-export/151899/4 "2020-05-19T15:28:26Z")

</div>

That PhD in education is finally paying off!

Nice work!

---

<div class="post-metadata">

### Author: ![jord8on](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jord8on/32/166809_2.png) [@jord8on](https://meta.discourse.org/u/jord8on)
#### Post date: [May 19, 2020, 5:30pm UTC](https://meta.discourse.org/t/data-explorer-query-add-additional-parameter-in-export/151899/5 "2020-05-19T17:30:55Z")

</div>

😝 Yes indeed! Thanks again 😉
