2017-02-22 87 views
0

我有一個請求從源刪除一些行。 此源包含3列:編號,類型,價值,和containes像一些數據:Informatica Cloud:刪除重複的條件

Id Type Value 
1  Master This is the first value 
1  Second This is a new value 
1  Third This is not a mandatory value 
2  Master Another one 
2  Third And again 
3  Second A new hope 
3  Third A third 
4  Second A single value 
... 

讓行的規則是:

如果單列爲一個標識,獲取現有值

否則: 如果相同的ID和「大師」多行存在,讓「大師」值

如果相同的ID和「大師」不存在,並且多行「二」存在,讓「第二」值爲

如果同一個Id和'Master'的多行不存在,'Second'不存在,'Third'存在,則獲取'Third'值。

在我的樣本的話,我想只提取:

Id Type Value 
1 Master This is the first value 
2 Master Another one 
3 Second A new hope 
4 Second A single value 

我嘗試分成3個不同的來源,並加入或查詢,但沒有發現任何參數丟棄重複行。

我該怎麼做?

由於提前, BR 澤維爾

回答

0

嘗試把它們通過分揀機通過ID命令,然後根據您的需求類型,最後通過ID ASC的aggregater分組,DESC(幸運的主人來之前第二哪按字母順序排在第三位)

+0

嗨,你的權利,我會嘗試這樣的,更簡單的比我的第一個解決方案。在此先感謝,我反饋如果使用我的數據類型。問候 – Cascador84

+0

如果您需要其他排序,您可以使用表達式將其轉換爲一些整數,然後進行排序。例如。 DECODE(Type,'Master',3,'Third',2,'Second',1)會選擇Second,Third和Master。 – Maciejg

+0

嗨,謝謝大家,它現在的作品現在更改爲最後的時間:) – Cascador84

0

查找可以轉換成信息圖的查詢。

create table test1 
(id integer, 
    type varchar2(100), 
    value varchar2(1000) 
); 

insert into test1 values (1,'Master','This is the first value'); 
insert into test1 values (1,'Second','This is a new value'); 
insert into test1 values (1,'Third','This is not a mandatory value'); 
insert into test1 values (2,'Master','This is the first value'); 
insert into test1 values (2,'Third','This is not a mandatory value'); 
insert into test1 values (3,'Second','This is the first value'); 
insert into test1 values (3,'Third','This is not a mandatory value'); 
insert into test1 values (4,'Second','mandatory value'); 
commit; 

select * from test1;  

From the below query "agg" part can be done in aggregator and decode function within aggregator transformation. 

Then use joiner to join agg part and actual table 

use filter to filter the required rows 

    with agg as 
    (select  max(case when type='Master' then 10 
       when type='Second' then 9 
       when type='Third' then 8 
       else 7 end) ms, 

      id 
     from test1 
    group by id 

) 
    select a.ms,b.* from agg a, test1 b 
     where a.id=b.id 
     and case when a.ms=10 then 'Master' 
       when a.ms=9 then 'Second' 
        when a.ms=8 then 'Third' 
        else 'noval2' 
        end =b.type;