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.
Answer Posted / 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 |
Post New Answer View All Answers
How to start the command-line sql*plus?
What are the advantages of sql? Explain
How to rename a table?
Which sql statement is used to return only different values?
Which is better varchar or nvarchar?
Explain raise_application_error.
What is a data definition language?
Can primary key be changed?
What are local and global Indexes and where they are useful.
What is the purpose of the primary key?
Write a program that shows the usage of while loop to calculate the average of user entered numbers and entry of more numbers are stopped by entering number 0?
Compare sql & pl/sql
What are different categories of sql commands?
How consistent is the view of the data between and within multiple sessions, transactions or statements ?
What is a recursive join sql?