# Unique rows in distributed table

**URL:** <https://discourse.julialang.org/t/unique-rows-in-distributed-table/36549>\
**Category:** New to Julia\
**Tags:** juliadb\
**Created:** [March 26, 2020, 11:58am UTC](https://discourse.julialang.org/t/unique-rows-in-distributed-table/36549 "2020-03-26T11:58:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakob](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jakob](https://discourse.julialang.org/u/Jakob)\
**Post date:** [March 26, 2020, 11:58am UTC](https://discourse.julialang.org/t/unique-rows-in-distributed-table/36549/1 "2020-03-26T11:58:38Z")

</div>

Hi,

how do I get the unique rows of a Distributed Table in JuliaDB?

`df = table(["a", "a", "a", "b", "b"], ["x", "x", "y", "x", "x"], names = (:X1, :X2), chunks = 2)`

```julia
julia> df
Distributed Table with 5 rows in 2 chunks:
X1 X2
────────
"a" "x"
"a" "x"
"a" "y"
"b" "x"
"b" "x"

```

Ideally, the output would look like this (i.e. be another Distributed Table):

```julia
Distributed Table with 3 rows in 2 chunks:
X1 X2
────────
"a" "x"
"a" "y"
"b" "x"

```

Best  
Jakob

---

<div class="post-metadata">

**Author:** ![Jakob](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jakob](https://discourse.julialang.org/u/Jakob)\
**Post date:** [March 27, 2020, 7:14pm UTC](https://discourse.julialang.org/t/unique-rows-in-distributed-table/36549/2 "2020-03-27T19:14:13Z")

</div>

Quick update, in case anyone else is look for this.  
Not sure if this is the way you’re supposed to do it but using `groupreduce` with an auxiliary column works:

```julia
df = transform(df, :count => ones(length(df)))

Distributed Table with 5 rows in 2 chunks:
X1 X2 count
───────────────
"a" "x" 1.0
"a" "x" 1.0
"a" "y" 1.0
"b" "x" 1.0
"b" "x" 1.0

df = groupreduce(+, t, (:X1, :X2), select = :count)

Distributed Table with 3 rows in 2 chunks:
X1 X2 +
─────────────
"a" "x" 2.0
"a" "y" 1.0
"b" "x" 2.0

```
