Hi guys I have this code:
SELECT
T1."T",
CASE WHEN T1."Count 2024 Q1" IS NOT NULL THEN T1."Count 2024 Q1" END AS "Q1",
CASE WHEN T1."Count 2024 Q2" IS NOT NULL THEN T1."Count 2024 Q2" END AS "Q2",
CASE WHEN T1."Count 2024 Q3" IS NOT NULL THEN T1."Count 2024 Q3" END AS "Q3",
CASE WHEN T1."Count 2024 Q4" IS NOT NULL THEN T1."Count 2024 Q4" END AS "Q4"
FROM T1
It is a table of 5 columns and 3 rows.
I would like create a new column and in the last 2 rows put a text for example:
New column:
Row 1 -> Tittle Column
Row 2 -> text A
Row 3 -> text B
so finally the main table (T1) will be with 6 columns and 3 rows. Do you know if is possible to make this in AlaSQL?
Hi @Matias G Labrana ,
You may try the following solution:
In the internal Table Transformer macro you use the following SQL structure:
SELECT ROWNUM() AS 'Rownum', *
FROM
(SELECT * FROM T*)
The internal SELECT part that is (SELECT * FROM T*) in my example stands for your original SQL query where you transform your table.
The external SELECT that is SELECT ROWNUM() AS 'Rownum', * FROM is used to add row numbers to your transformed table.
As a result, you will see smth like this:
Now we can join this table with an additional mini table using the unique 'Rownum' column:
SELECT 'Column 1', 'Column 2', 'Column 3', 'Additional column'
FROM T1
LEFT JOIN T2 ON T1.'Rownum' = T2.'Rownum'
Please note that I've taken my screenshots for Data Center where you can nest macros directly.
For Cloud you need to insert the Table Toolbox macro on the page, wrap your tables into it and then go to the macro settings & create the described structure inside the macro shell.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.