How to merge tables and delete duplicates from table cells?
Asked by Charfi Ouacef:

Hello together,

I would like to merge these two tables from different pages:

![Screenshot 2023-05-05 175436.png](/t5/image/serverpage/image-id/255536iD7847081983F2BFE/image-size/large?v=v2&px=999 "Screenshot 2023-05-05 175436.png")

to this final table:

![Screenshot 2023-05-05 175554.png](/t5/image/serverpage/image-id/255537iCEB0674EF349B8ED/image-size/large?v=v2&px=999 "Screenshot 2023-05-05 175554.png")

My problem currently is that i have no idea how to remove the duplicate values.

Can somebody please help me?


Answers:
author: Katerina Rudkovskaya [Stiltsoft]
body: Hi [@Charfi Ouacef](/t5/user/viewprofilepage/user-id/5212495),  

Please try the following SQL query for the case:  

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

SELECT  
FORMATWIKI(SUM('male' + "\\n")) AS 'male',  
FORMATWIKI(SUM(DISTINCT('beard') + "\\n")) AS 'beard',  
FORMATWIKI(SUM(DISTINCT('shoe size') + "\\n")) AS 'shoe size'  
FROM (SELECT \* FROM T1 OUTER JOIN T2 ON T1.'male' = T2.'male')  

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

Seems it can help your case.

comments: author: Charfi Ouacef
body: Thats exactly what I was looking for. Thank you very much!


author: Charfi Ouacef
body: Hi [@Katerina Rudkovskaya \[Stiltsoft\]](/t5/user/viewprofilepage/user-id/3738229) ,

just one little question. If I have more information in a cell, then the words are simply lined up.

![Screenshot 2023-05-12 145256.png](https://community.atlassian.com/t5/image/serverpage/image-id/256919iBB859CFDD90A1802/image-size/large?v=v2&px=999 "Screenshot 2023-05-12 145256.png")

SELECT  
FORMATWIKI(SUM('male' + "\\n")) AS 'male',  
FORMATWIKI(SUM(DISTINCT('beard') + "\\n")) AS 'beard',  
FORMATWIKI(SUM(DISTINCT('shoe size') + "\\n")) AS 'shoe size'  
FROM (SELECT \* FROM T1 OUTER JOIN T2 ON T1.'male' = T2.'male')

![Screenshot 2023-05-12 145359.png](https://community.atlassian.com/t5/image/serverpage/image-id/256920i2A897AF216D36707/image-size/large?v=v2&px=999 "Screenshot 2023-05-12 145359.png")

Is there a way to separate the words to merge them like discussed? I also have the possibility to change the original tables but i don't want to create a row for every Information in the cell.

Best regards  
Ouacef


author: Stiltsoft support
body: The contents of the specific cell can't be treated separately.

If "John" has

***yes(enter)***

***maybe(enter)***

***no***

in his cell, then all the cells' contents will be compared with the other cells.

So, your result that is

***yesmaybeno***

is correct.

If such behavior suits you and the question is that the result text is unreadable, you may just use spaces:

***yes (enter)***

***maybe (enter)***

***no***

Then you'll get

***yes maybe no***

as a result.

If you need to compare items separately, you indeed need to create several rows for "John". And don't forget to use the DISTINCT function for 'male' column, otherwise you'll get several "Johns".


author: Fabio Racobaldo _Herzum_
body: Hi [@Charfi Ouacef](/t5/user/viewprofilepage/user-id/5212495) and welcome,

tables in Confluence are not structured items so you should do that manually. There are not builtin features to do that.

Fabio

comments: author: Charfi Ouacef
body: Hi [@Fabio Racobaldo _Herzum_](/t5/user/viewprofilepage/user-id/781528) ,

thank you very much for the fast answer. Is there no possibility to solve the problem with table transformation and SQL?


author: Fabio Racobaldo _Herzum_
body: hey [@Charfi Ouacef](/t5/user/viewprofilepage/user-id/5212495) ,

tables are stored as text in Confuence DB so you can't manage merge from text using SQL query.

Fabio


author: Charfi Ouacef
body: Hi [@Fabio Racobaldo _Herzum_](/t5/user/viewprofilepage/user-id/781528) ,

In sql it is possible to join the same text in cells using "Group By" command. Is there no possibility to use another operator, something like FORMATWIKI(SUM...) or "Select Distinct"??

[@Katerina Kovriga {Stiltsoft}](/t5/user/viewprofilepage/user-id/1464746) do you maybe have a solution for the problem?

Best regards  
Ouacef


Tags: cloud

confluence-cloud

confluence-server

filter

server

table

table-filter

table-filter-and-charts

table-transformer