根据前5个列值填充第6列

时间:2015-07-09 22:51:23

标签: sql-server ssis

请帮我根据SSIS中的5列ActiveStatus InactiveStatus LapsedStatus NoSpecialEventsStatus SpecialEventsStatus的值填充Marketingsegmentscore

if active= 1 and inactive = 0 and lapsed = 0 and spec_flag = 1 and nospec_flag = 0 marketing_grid_score = 1.
if active= 1 and inactive = 0 and lapsed = 0 and spec_flag = 0 and nospec_flag = 1 marketing_grid_score = 2.
if active= 1 and inactive = 0 and lapsed = 0 and spec_flag = 1 and nospec_flag = 1 marketing_grid_score = 3.
if active= 0 and inactive = 1 and lapsed = 0 and spec_flag = 1 and nospec_flag = 0 marketing_grid_score = 4.
if active= 0 and inactive = 1 and lapsed = 0 and spec_flag = 0 and nospec_flag = 1 marketing_grid_score = 5.
if active= 0 and inactive = 1 and lapsed = 0 and spec_flag = 1 and nospec_flag = 1 marketing_grid_score = 6.
if active= 0 and inactive = 0 and lapsed = 1 and spec_flag = 1 and nospec_flag = 0 marketing_grid_score = 7.
if active= 0 and inactive = 0 and lapsed = 1 and spec_flag = 0 and nospec_flag = 1 marketing_grid_score = 8.
if active= 0 and inactive = 0 and lapsed = 1 and spec_flag = 1 and nospec_flag = 1 marketing_grid_score = 9.


    ╔═══════════════╦══════════════╦════════════════╦══════════════╦═══════════════════════╦═════════════════════╦═══════════════════════╗
    ║ AccountNumber ║ ActiveStatus ║ InactiveStatus ║ LapsedStatus ║ NoSpecialEventsStatus ║ SpecialEventsStatus ║ MarketingSegmentScore ║
    ╠═══════════════╬══════════════╬════════════════╬══════════════╬═══════════════════════╬═════════════════════╬═══════════════════════╣
    ║         12345 ║            1 ║              0 ║            0 ║                     1 ║                   1 ║                     0 ║
    ║         45678 ║            0 ║              1 ║            0 ║                     1 ║                   1 ║                     0 ║
    ║         79011 ║            0 ║              0 ║            1 ║                     1 ║                   0 ║                     0 ║
    ║        112344 ║            0 ║              0 ║            1 ║                     1 ║                   0 ║                     0 ║
    ║        145677 ║            1 ║              0 ║            0 ║                     1 ║                   1 ║                     0 ║
    ║        179010 ║            0 ║              0 ║            1 ║                     1 ║                   1 ║                     0 ║
    ╚═══════════════╩══════════════╩════════════════╩══════════════╩═══════════════════════╩═════════════════════╩═══════════════════════╝
  • 列表项

212343 0 0 1 1 1 0

2 个答案:

答案 0 :(得分:0)

您是否尝试使用CASE ... END。基本上你只想做像

这样的事情
<dependency>
    <groupId>cz.jirutka.unidecode</groupId>
    <artifactId>unidecode</artifactId>
    <version>1.0.1</version>
</dependency>

答案 1 :(得分:0)

您将需要派生列任务,并在派生列中使用以下表达式设置MarketingSegmentScore列的值。

active== 1 && inactive == 0 && lapsed == 0 && spec_flag == 1 && nospec_flag == 0 ? 1 :(
active== 1 && inactive == 0 && lapsed == 0 && spec_flag == 0 && nospec_flag == 1 ? 2 :(
active== 1 && inactive == 0 && lapsed == 0 && spec_flag == 1 && nospec_flag == 1 ? 3 :(
active== 0 && inactive == 1 && lapsed == 0 && spec_flag == 1 && nospec_flag == 0 ? 4 :(
active== 0 && inactive == 1 && lapsed == 0 && spec_flag == 0 && nospec_flag == 1 ? 5 :(
active== 0 && inactive == 1 && lapsed == 0 && spec_flag == 1 && nospec_flag == 1 ? 6 :(
active== 0 && inactive == 0 && lapsed == 1 && spec_flag == 1 && nospec_flag == 0 ? 7 :(
active== 0 && inactive == 0 && lapsed == 1 && spec_flag == 0 && nospec_flag == 1 ? 8 :(
active== 0 && inactive == 0 && lapsed == 1 && spec_flag == 1 && nospec_flag == 1 ? 9 :0))))))))