Hi, can someone please guide me on below query.
I have sql query like, select sum(col-1), col-2 from table where col-3 ='Jmh'
Required result like
filed_name
col-1
col-2
col-3
OR
filed_name-1 filed_name-2 filed_name-3
col-1 col-2 col-3
Solved! Go to Solution.
Hi you can use sql editor to check or write your query
is there any another way without editor to get the same result.
As it has sum(col-1) and it is giving the sum and not name of column. We want column name in result.
Can you just alias that column in your query? Something like: sum(col-1) AS col-1
Otherwise, in Alteryx, you can use the Dynamic Rename Tool in a variety of capacities to rename your columns. That would depend on what you have and what you desired output is (more precisely).
can plz guide on, How separates the columns names from sql query
example-- select sum(col-1), max (col-2) from table;
Field_name
co-1
co-2
Can you provide some sample input and current output and expected output? I do not fully understand what you are looking for.
Than u for ur attention.
It is just a sql select query and whatever aggregate function applied on a column only those column or columns required to separate and want to arrange in row-wise. Like ,
example-- select sum(col-1), max (col-2) from table;
Field_name
co-1
co-2
It sounds like you might need the Transpose Tool. A sample input and output would really help (for example):
EXAMPLE Sample Input:
col-3 | sum(col-1) | max(col-2) |
A | 5 | 7 |
B | 1 | 0 |
EXAMPLE Sample Output:
col-3 | Name | Value |
A | sum(col-1) | 5 |
B | sum(col-1) | 1 |
A | max(col-2) | 7 |
B | max(col-2) | 0 |
This will go a long way in providing the specifics needed to assist you with your particular use-case. The example above is perfect for the Transpose Tool.