Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Delete data whose key exists more than once

Hi,

I need to clear a table so that every key "Material_Period" exists just once.

Distinct does not work since other fields are different.

where not exists brought errors.

Any idea?

Plant% period% MaterialCost
11300100
21300120
1130180
12300110
2230390


Right now I'm doing a detour like that:







Kalk_Temp:

LOAD

PLANT

,

replace

(ltrim(replace(MATERIAL, '0', ' ')), ' ', 0) as MATERIAL

,

makedate

(left(SPBUP,4),right(SPBUP,2)) as Datum

,

replace

(ltrim(replace(MATERIAL, '0', ' ')), ' ', 0)&'_'&SPBUP as Key

,

// LOTSIZE,

// LOTSIZE_UNIT,

ZHK

,

ZMAT

FROM

U:\ZKALKMAT.qvd

(

qvd

)

where

SPBUP >

201003

and



VRSIO =

0

and



right(MATERIAL,6) >

315000

;

qualify

*;

unqualify

'Key';

Kalk0001:

LOAD

*

resident

Kalk_Temp

where

PLANT = 0001

;

Kalk0003:

LOAD

*

resident

Kalk_Temp

where

PLANT <>0001

;

drop

table

Kalk_Temp;



unqualify

*;

Kalkfinal:

Load

*

resident

Kalk0001;

Load

*

resident

Kalk0003

where

not exists (Key)

;





Thanks for your help!

0 Replies