472,133 Members | 1,153 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

Result Row


Dear All,

Can we do multiple result row as a single row while selection ..?

Request you to provide the SQL if we can achieve this...

For Eg,

Table Name = Employee
id - EmployeeName - addresstype - address1 - address2 - City
1 - AAA - permanent - 231 - First Street - XYA
2 - AAA - Temporary - 343 - Second Street - XYA

Expecting Result as a Single row as below,

id - EmployeeName - Address1 - Address2
1 - AAA - 231/First Street/XYA - 343/Second Street/XYA

Thanks in advance

Rgds,
Ganapathi sundaram.G
Mar 12 '08 #1
1 1296
Ganapathi sundaram wrote:
Can we do multiple result row as a single row while selection ..?

Request you to provide the SQL if we can achieve this...

For Eg,

Table Name = Employee
id - EmployeeName - addresstype - address1 - address2 - City
1 - AAA - permanent - 231 - First Street - XYA
2 - AAA - Temporary - 343 - Second Street - XYA

Expecting Result as a Single row as below,

id - EmployeeName - Address1 - Address2
1 - AAA - 231/First Street/XYA - 343/Second Street/XYA
If each employee will have at most two addresses (permanent and
temporary), then this should work:

select
id,
max(EmployeeName) EmployeeName,
max(case addresstype
when 'permanent' then address1 + '/' + address2 + '/' + city
end) Address1,
max(case addresstype
when 'temporary' then address1 + '/' + address2 + '/' + city
end) Address2
from Employee
group by id
Mar 12 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by maceo | last post: by
3 posts views Thread by Michael C# | last post: by
12 posts views Thread by Mick_fae_Glesga | last post: by
9 posts views Thread by JRough | last post: by
3 posts views Thread by JRough | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.