Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 select query How to compare with another field

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2012-11-27 : 16:27:09
Within my select how can i compare the two field values and if match then 1 else 2, how can do that is it possible.

select p_Al.Alias, p_Al.Fin_Number,

case when p_p_r.PRSNL_PERSON_ID = p_Al.Alias then 1 else 2

as PCP

from table1 inner join table2 on (p_p_r.person_id = p_al.person_id)


Thank you very much for the helpful info.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-11-27 : 16:30:41
quote:
Originally posted by cplusplus

Within my select how can i compare the two field column values and if match then 1 else 2, how can do that is it possible.

select p_Al.Alias, p_Al.Fin_Number,

case when p_p_r.PRSNL_PERSON_ID = p_Al.Alias then 1 else 2 END

as PCP

from table1 inner join table2 on (p_p_r.person_id = p_al.person_id)


Thank you very much for the helpful info.


You are very close, see red highlight above.
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2012-11-27 : 16:48:08
Lamprey Thank you very much for the help.


Go to Top of Page
   

- Advertisement -