T-SQL Row Concatenate with a Twist??# Database - 数据库
i*a
1 楼
have a table in the following data:
ContactID____Type____Value
1**********************[email protected]
123_________phone___555-555-5555
123_________fax_____888-888-8888
how do I do a select statment to get it into 1 result line like this:
ContactID, ContactEmail, ContactPhone, ContactFax
123, a*[email protected], 555-555-5555, 888-888-8888
I am using
select
case type
when 'email' then Value AS ContactEmail
end,
case type
when 'phone' then Value AS ContactPhone
end,
case type
when 'fax' then Value AS ContactFax
ContactID____Type____Value
1**********************[email protected]
123_________phone___555-555-5555
123_________fax_____888-888-8888
how do I do a select statment to get it into 1 result line like this:
ContactID, ContactEmail, ContactPhone, ContactFax
123, a*[email protected], 555-555-5555, 888-888-8888
I am using
select
case type
when 'email' then Value AS ContactEmail
end,
case type
when 'phone' then Value AS ContactPhone
end,
case type
when 'fax' then Value AS ContactFax