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 |
|
jpockets
Starting Member
45 Posts |
Posted - 2007-06-12 : 11:53:53
|
What i'm trying to do is if this column dt.IN_DIV_NO is populated take that value first if it's null than rr.AIQ_R_DIVISION_NO and if that column is null than rr.F_DIVISION_NO. This is what i came up with, will it evaluate the way i need it to? case When dt.IN_DIV_NO is not null then dt.IN_DIV_NO else case when rr.AIQ_R_DIVISION_NO is null then rr.F_DIVISION_NO end end as Current_DIV Thank-you |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-06-12 : 11:56:21
|
Why not Coalesce()?Coalesce(dt.IN_DIV_NO, rr.AIQ_R_DIVISION_NO, rr.F_DIVISION_NO) Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-06-12 : 11:58:37
|
yeah something like this: Current_DIV = CASE WHEN dt.IN_DIV_NO IS NULL THEN ( CASE WHEN rr.AIQ_R_DIVISION_NO IS NULL THEN rr.F_DIVISION_NO ELSE rr.AIQ_R_DIVISION_NO END) ELSE dt.IN_DIV_NO END Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
jpockets
Starting Member
45 Posts |
Posted - 2007-06-12 : 12:24:25
|
| Thanks for the help, i never knew about the COALESCE before did some research and it's excatly what i need, thank-you for the help! |
 |
|
|
|
|
|