MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to concatenate two rows in single row?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
sonika2008
Beginner


Joined: 17 Aug 2007
Posts: 20
Topics: 9

PostPosted: Wed Sep 12, 2007 12:11 pm    Post subject: how to concatenate two rows in single row? Reply with quote

I have a SQL statement that fetches ID, SR.No, place information.
like this:-

    ID Sr. No Place
    123 x abc
    x def
I want that if the Sr.No is same , than palce information display in one row
like this:-
    ID Sr. No Place
    123 x abc def

Is there any way to concatenate the two lines become one?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Sep 12, 2007 12:23 pm    Post subject: Reply with quote

sonika2008,

show us your sql as to how you are getting the rows in that fashion

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
viswanathan
Beginner


Joined: 17 Jan 2006
Posts: 26
Topics: 13

PostPosted: Thu Sep 13, 2007 1:16 pm    Post subject: Reply with quote

Hi Sonika,


Please try this


select a.id, a.srno,a.place,b.fieldname from table1 a, table2 b
where a.srno = b.srno

If my understanding is wrong..please provide us more info in this regard.

-Vishwa
Back to top
View user's profile Send private message
sriramla
Beginner


Joined: 22 Feb 2003
Posts: 74
Topics: 1

PostPosted: Thu Sep 13, 2007 2:16 pm    Post subject: Reply with quote

Viswanathan, your query would result in duplicates. If there are 2 rows with same id, the poster want to combine them into a single row. But the join you have would give 4 rows (2 * 2).
Back to top
View user's profile Send private message
A_programmer
Beginner


Joined: 15 Oct 2007
Posts: 2
Topics: 0
Location: USA

PostPosted: Wed Oct 31, 2007 7:44 am    Post subject: Reply with quote

What about if there are multiple rows with the same Sr. No. ?
How can you dynamically add columns ????
_________________
Its not necessary to change. Survival is not mandatory.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group