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.
Author |
Topic |
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2012-12-07 : 13:58:03
|
Want to write a case within select comparing other column within the select statement:Is this the right way both fields are numeric fields:CASE WHEN P_P_R.PRSNL_PERSON_ID = prsnl_al.alias then 1ELSE 2 END as PCPThanks a lot for the helpful info. |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-12-07 : 14:05:01
|
Assuming you want to return 1 when column PRSNL_PERSON_ID in table (or table alias) P_P_R has the same value as column "alias" in table (or table alias) prsnl_al it is correct. If the two columns are not equal, or if one or both of them are null, you will get 2. |
|
|
|
|
|