0

I have this table:

Name    Address                  Code
James   CT                       Homeaddress
Mark    [email protected]           Email
John    [email protected]         homeemail
...

This is what I want:

Name        Homeaddress      Email           homeemail
james       CT
mark                         [email protected]
john                                         [email protected]

I am creating a view and dont have privilages to alter the base tables. I was thinking maybe an IF statement might help

1
  • ITS KIND OF DIFFERENT AS I DONT HAVE ANY NUMBERS
    – Rafey
    Jul 19, 2013 at 16:40

1 Answer 1

1

I think you can use CASE expression. Something like that:

SELECT Name,
  CASE Code WHEN 'Homeaddress' THEN Address ELSE NULL END AS Homeaddress,
  CASE Code WHEN 'Email' THEN Address ELSE NULL END AS Email,
  CASE Code WHEN 'homeemail' THEN Address ELSE NULL END AS homeemail
FROM yourtable
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.