Limit or group duplicates in table based on one field?

My spreadsheet looks like this. Can exclude duplicates from it based on login?(Counter is preferable too, to show how many of them=) but even hiding would be more then enough.
Could you advise please?


You could use the Query JSON with SQL resource to filter down the table data with a DISTINCT clause:

Select distinct login, yourOtherFields from {{}}

Or filter the table data array with a lodash uniq function:

_.uniqBy(, 'login')

1 Like

Wow, didn't know something like that is possible. Lodash solves the problem, but how to use your second option with Query JSON with SQL? Where to put it in retool?

One of the preset resources is called Query JSON with SQL:


You can use this resource in apps and workflows!

Could you advise on what i do wrong?

And the getdata request

Since the getData query is a SQL query, you might be able to just use ... from {{getData}}

This seems to be how they describe selecting from a SQL query in the Retool Documentation for Query JSON with SQL (Query JSON with SQL | Retool Docs)

Did a little testing.

It seems like you actually want to make the query data an array for it to be properly selectable:

select distinct login, id from {{formatDataAsArray(}}

Thank you pyrrho! What a struggle it was, to make it work) There is always a space needed after formatDataAsArray - otherwise it didn't work. Now it looks like this, BUT) Logins are still not unique)

Weird about the space... I don't think I've needed to dot that before, but hey! It works. If you just want distinct logins, then only query the login value. When you include the id, it is returning distinct pairs of login, id. If you query select distinct login from {{formatDataAsArray(}} you will get the list of only the unique login values.

I'm pretty sure you could rejoin the data on itself to get the count of Ids for each unique login, but my SQL isn't that good for me to remember off the top of my head the right syntax for that.

1 Like

Thank you so much, Pyrrho, for all your help. Now I understand.
Your first solution with lodash turned out to be much easier and works without joins, so I'll stick with it. However, I was very curious about the other SQL-like option.
Have a great day!

//gosh i love this community!


Love to see all the knowledge sharing and partnership on working toward solutions, and love to see the love for the community expressed too!! Great work and thank you for sharing @Bogdan_Mind @pyrrho :tada: :sparkles: