Tuesday, February 14, 2012

Data transformations

I need to know if I can do this with a CASE statement:
I have a column (Name) in table start that I want to compare to another
column (ProperName) in table finish. If the Name matches any
ProperName then I want to display TransName from finish.
Can I do this:
CASE
WHEN start.name = finish.propername THEN TransName
END
Thanks!!!!Try,
select a.c1, ..., isnull(a.[name], b.TransName)
from dbo.start as a left join dbo.finish as b
on a.[name] = b.ProperName
AMB
"CJEN" wrote:

> I need to know if I can do this with a CASE statement:
> I have a column (Name) in table start that I want to compare to another
> column (ProperName) in table finish. If the Name matches any
> ProperName then I want to display TransName from finish.
> Can I do this:
> CASE
> WHEN start.name = finish.propername THEN TransName
> END
>
> Thanks!!!!
>|||Sorry,
select a.c1, ..., case when b.ProperName is not null then b.TransName else
a.[name] end as the_name
from dbo.start as a left join dbo.finish as b
on a.[name] = b.ProperName
AMB
"Alejandro Mesa" wrote:
> Try,
> select a.c1, ..., isnull(a.[name], b.TransName)
> from dbo.start as a left join dbo.finish as b
> on a.[name] = b.ProperName
>
> AMB
> "CJEN" wrote:
>

No comments:

Post a Comment