have table with two columns with datatypes as number and
varchar and the values in
A column like 1,2,3 AND B column values like a,b,c.
now need to display data in a single column as 1,a,2,b,3,c.
Answers were Sorted based on User's Feedback
Answer / kavitha neditunta
select WM_CONCAT(a||','||b)
from tablename;
Is This Answer Correct ? | 10 Yes | 1 No |
Answer / prativa mishra
select rtrim(xmlagg(xmlelement("c",A||' ,'||B||',')).extract('//text()'),',') single_column
from table_name
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / krishna
select rtrim(xmlagg(xmlelement(E,
EMPID||','||NAME||','||'')).extract('//text()') ,',')
empid from emp1
Is This Answer Correct ? | 7 Yes | 3 No |
Answer / sunaksha
select listagg( A||','||B || ',') within group (order by A) from table_name;
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / saravanan
Try this way!
create table stest(num int,name varchar(10),value numeric
(10,2));
insert into stest values(101,'SARAN',1000.58);
insert into stest values(102,'KALA',1200.18);
insert into stest values(103,'AYYA',3000.40);
insert into stest values(104,'RATNA',4000.57);
SELECT * FROM STEST;
declare @str varchar(2000);
set @str = null;
select @str=ISNULL(@str+',','')+ltrim(STR(num))+','+name
from stest
select @str;
Is This Answer Correct ? | 3 Yes | 2 No |
Answer / prativa mishra
select rtrim(xmlagg(xmlelement("c",A||' ,'||B||',')).extract('//test()'),',') single_column
from table_name
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sona mathew
select listagg(c1||','||c2,',')
within group (order by c1||','||c2)
from tab;
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vi.s.senthilkumar
select column1||','||column2 result from tableName;
Is This Answer Correct ? | 2 Yes | 3 No |
what command is used to create a table by copying the structure of another table including constraints ?
what is a materialized view? : Sql dba
How many types of functions are there in sql?
how will u find statistics of a database objects?
How can we implement rollback or commit statement in a trigger?
How to create a view on a table which does not exists
what is pragma ?
1) Synonyms 2) Co-related Subquery 3) Different Jobs in Plsql 4) Explain Plan 5) Wrap 6) Query Optimization Technique 7) Bulk Collect 8) Types of index 9) IF primary key is created then the index created ? 10) Foreign Key 11) Exception Handling 12) Difference Between Delete and Trunc 13) Procedure Overloading 14) Grant Revoke 15) Procedure Argument types. 16) Functions. 17) Joins
What is denormalization in a database?
Define tables and fields in a database
What is triggering circuit?
What is lexical units in pl sql?