How to delete duplicates rows to keep only one in Transformer table (Confluence) ?
Asked by Raphael Chagnoleau:

Afternoon everyone,

Here is my use case - I have multiple tables with hundreds of rows each and I am using the Transformer macro to merge them all into one.

++Problem with that:++ few rows are duplicated (all data in each columns are identical).

++My question is:++ What SQL query should I use to delete (or hide) duplicated rows to only keep one in the table ?

++Example:++

Initial Table:

|---------|-------------|
| **Key** | **Summary** |
| 10      | Hello World |
| 50      | Apple       |
| 33      | Cheese      |
| 10      | Hello World |

Expected Table:

|---------|-------------|
| **Key** | **Summary** |
| 10      | Hello World |
| 50      | Apple       |
| 33      | Cheese      |

++Partial solution:++ I have encountered a question previously asked on that matter which uses below SQL query, but all rows are deleted:

```
SELECT DISTINCT * FROM T1
```

Thanks for your help, and have a great summer !


Answers:
author: Katerina Kovriga {Stiltsoft}
body: Hi [@Raphael Chagnoleau](/t5/user/viewprofilepage/user-id/4483547) ,

At first I want to mention our new feature regarding the [Table Excerpt/Table Excerpt Include](https://docs.stiltsoft.com/display/public/TFAC/How+to+use+Table+Excerpt+and+Table+Excerpt+Include+macros) macros: if your tables are manually created, I assume that you reuse them with the help of the Table Excerpt macros and collect them with the help of the Table Excerpt Include macro.

If this is the case, then you don't need the Table Transformer macro to merge your tables into one big report - just tick the corresponding checkbox into the Table Excerpt Include macro settings (and you may show additional page meta data as well):

![Thu 10-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/152049iE285298CB0F0645F/image-size/large?v=v2&px=999 "Thu 10-1.png")

If your tables are based on the Jira Issues macros, then you may use the Table Transformer macro to combine them with the help of the Merge preset (as, I suppose, your are doing now).

The easiest way to get rid of the duplicate rows is to go to the Custom transformation and use the following SQL query:

SELECT DISTINCT \* FROM  
(SELECT \* FROM T\*)

![Thu 10-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/152053iE5CC67E49ED77913/image-size/large?v=v2&px=999 "Thu 10-3.png")

![Thu 10-6.png](https://community.atlassian.com/t5/image/serverpage/image-id/152057i082D345368D4B512/image-size/large?v=v2&px=999 "Thu 10-6.png")

![Thu 10-7.png](https://community.atlassian.com/t5/image/serverpage/image-id/152058i4138ADBF14A87C42/image-size/large?v=v2&px=999 "Thu 10-7.png")

Hope this may help your case.

comments: author: Raphael Chagnoleau
body: Katerina, thank you so much for your help - I used your second solution (create 2 Transformer tables) and it works perfectly !

As my table had a couple of Columns (10 or so), I displayed all columns name into the SQL query to make them appear in the list.

Once again, thanks a lot, you saved me a lot of time and brain cells !

Have a great day,

Rapha?l


author: Katerina Kovriga {Stiltsoft}
body: I've changed the original answer (not sure what version you have seen), so you may try the option with one Table Transformer and the following SQL query:

SELECT DISTINCT \* FROM  
(SELECT \* FROM T\*)


Tags: confluence-server

server