SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 select query How to compare with another field
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cplusplus
Aged Yak Warrior

540 Posts

Posted - 11/27/2012 :  16:27:09  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 11/27/2012 :  16:30:41  Show Profile  Reply with Quote
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

540 Posts

Posted - 11/27/2012 :  16:48:08  Show Profile  Reply with Quote
Lamprey Thank you very much for the help.


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000