Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
is it possible to put an instruction in the loading script in order to change some information in the data?
For example, I have these columns MRC, CIRCUIT and COUNTRY, and I know I have an issue with the DB I am using and I would like to give this kind of instruction:
where the CIRCUIT name is ending with 5 and the COUNTRY is Spain , replace the value in the column MRC with 10.
Is it possible?
Many thanks in advance
Maybe like
LOAD
If( CIRCUIT Like '*5' and COUNTRY ='Spain', 10, MRC) as MRC,
CIRCUIT,
COUNTRY
FROM ....;
Maybe like
LOAD
If( CIRCUIT Like '*5' and COUNTRY ='Spain', 10, MRC) as MRC,
CIRCUIT,
COUNTRY
FROM ....;
It is working
and what if I need to add more conditions like this one for the same field?
Just add them... as long as all information originate from within the same record, it should be quite easy.
Thank you Stefan,
you were really helpful
Just use Match or Wildmatch in your IF as suggested by Stefan.
You can also use like
IF(Wildmatch(CIRCUIT, '*5', '*8', '*2') AND Match(COUNTRY, 'Spain', 'Swedan'), 10, MRC) AS MRC
Hi,
thank you for your answer
what now I need to do is to add more conditions, on the same fields but on different records and replacing the wrong data with different information.
Using your example, what if I want to use for Sweden 15, and instead of CIRCUIT the STATUS?
Are you looking for something like
LOAD
If( CIRCUIT Like '*5' and COUNTRY ='Spain', 10,
If(STATUS Like '*5' and COUNTRY = 'Sweden', 15, MRC)) as MRC,
CIRCUIT,
COUNTRY,
STATUS
FROM ....;
But this can get quite messy if you are applying a lot of these if() statements.
Uhm, you are right, it is messy.. but I will not use more than 3 conditions
Thank you so much
AS Stefan suggested you might have to use nested IF's using Match and wildmatch too.
BTW what is your complete requirement here?