Table Transformer - Column Rename Moves Column to End of Table

Zowi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 23, 2023

When I rename a column with the below command, it creates a new column at the end of the table with the new name.

How do you just rename a column and have it stay in the same order?

FORMATWIKI("{cell:width=100px}", 'Wave', "{cell}") AS 'Phase',

1 answer

4 votes
Katerina Rudkovskaya _Stiltsoft_
Atlassian Partner
August 24, 2023

Hi @Zowi,

You may just list your columns in that particular order that you want them to be present in the table:

SELECT
'Column_name 1', 'Column_name 2',
FORMATWIKI("{cell:width=100px}", 'Some column name', "{cell}") AS 'Column_name 3',
'Column_name 4', 'Column_name 5'
FROM T1

Note that you don’t need to list the 'Some column name' column that we rename, otherwise you’ll get two columns with the same contents.


The option to SELECT * and then rename your column indeed shows all the existing columns as they are and creates a new column at the end of the table.

Zowi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 24, 2023

Hi Katerina, 

I inserted a new table with 5 columns named as Column_name 1, 2, 3, 4, & 5, and copy pasted your query as-is and nothing changed. Column_name 3 was still named column_name 3 and no new columns were created called Some column name.


What am I doing wrong?

Thanks!

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2023

Hi @Zowi ,

It seems that you misunderstood the query:

FORMATWIKI("{cell:width=100px}", 'Some column name', "{cell}") AS 'Column_name 3',

renames the 'Some column name' to 'Column_name 3'.

So, your table should be Column_name 1, Column_name 2, Some column name, Column_name 4, Column_name 5.

As a result, you'll get Column_name 1, 2, 3, 4, & 5, where 'Column_name 3' is the former 'Some column name' with a specified width. And if we list it on the third place, it will be also displayed as the third column.

Fri 1-1.png

SELECT
'Column_name 1', 'Column_name 2',
FORMATWIKI("{cell:width=200px}", 'Some column name', "{cell}") AS 'Column_name 3',
'Column_name 4', 'Column_name 5'
FROM T1

Fri 1-2.png

Note that in your original query the width was set as 100 and here I changed it to 200 just to show the difference on the screenshot.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events