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 |
Rich75
Starting Member
8 Posts |
Posted - 2013-12-10 : 15:22:42
|
How could I do this more efficiently? Is there a way to group both conditions under the same Case When?CASE WHEN ACCOUNT.BILL_TYPE_CODE='Regular' THEN ACCOUNT.ACCOUNT_KEY ELSE CUSTOMER.ACCOUNT_KEY END AS ACCOUNT_KEY, CASE WHEN ACCOUNT.BILL_TYPE_CODE='Regular' THEN ACCOUNT.ACCOUNT_NUMBER ELSE CUSTOMER.ACCOUNT_NUMBER END AS ACCOUNT_NUMBER |
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2013-12-10 : 15:32:17
|
On which conditions you need to merge these two different COLUMNS.Like one possibility if ACCOUNT_KEY is null, use ACCOUNT_NUMBER soCASE WHEN ACCOUNT.BILL_TYPE_CODE='Regular' THEN ISNULL(ACCOUNT.ACCOUNT_KEY,ACCOUNT.ACCOUNT_NUMBER)otherwise there is no logic to group both two different columns--------------------------http://connectsql.blogspot.com/ |
|
|
Rich75
Starting Member
8 Posts |
Posted - 2013-12-10 : 15:37:13
|
quote: Originally posted by lionofdezert On which conditions you need to merge these two different COLUMNS.Like one possibility if ACCOUNT_KEY is null, use ACCOUNT_NUMBER soCASE WHEN ACCOUNT.BILL_TYPE_CODE='Regular' THEN ISNULL(ACCOUNT.ACCOUNT_KEY,ACCOUNT.ACCOUNT_NUMBER)otherwise there is no logic to group both two different columns--------------------------http://connectsql.blogspot.com/
Ok I understand. Thanks for your help. |
|
|
|
|
|