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',
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.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.