469,138 Members | 1,346 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

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 1251
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
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.