I have this table:
| arrs |
|:----|
| {10000,10000,10000,10000} |
| {100,200,300} |
| {400,500,600} |
| {100,200,600} |
How get this result?
| uniques |
|:-------|
| 10000 |
| 100 |
| 200 |
| 300 |
| 400 |
| 500 |
| 600 |
Or this result?
| arrUniques |
|:----|
| {10000,100,200,300,400,500,600} |
See -> fiddle
2
Answers
You should be able to use
UNNEST()
along withDISTINCT
here:You can use
Distinct unnest
to display unique results as per your first scenario :For your second scenario displaying result in single array you can add
array_agg
: