sql - Alternative to like/ like any?... regexp? -


I have a terabyte dataset that looks like the following:

  Customer_ID | Targeting_pradesh 12 | Targ = EU, targ =! Eu.Fr 34 | Targ = Asia 56 | targ =! EU   

'!' Means 'not equal' for example, in line # 1, the client wants to target the European Union, but wants to exclude France.

I want to create a region that has flag (with '1') in any row where 'positive' targeting is. From 'positive' targeting, I am mentioning any row where clearly there is a specific area ('negative' targeting will be where a sector is clarified, such as boycott of France in Row # 1) For example, Line # 1 includes both positive and negative targeting, line # 2 includes only positive targeting, only negative targeting included in line # 3 Is.

The problem is facing that a simple matter statement will not work (as far as I can tell) I have tried two statements below:

  ( When target_region is like '% targ =%', then 1 and 0 end) as the target_ flag (when (target_region '% targ =%';) and (target_region not '% targ =!%';)) Then The first 1 above statement does not work as target_ flag   

because it 'targ =' and 'targ =!

for both of the two statements given above Does not because it's the lines 1, which are only positive targeting such as, line # 1 (above) will return a 0 (I want to return it 1)

Note that the value after 'targ =' can also be a number E.g., 'Targ = 12345'

How can I complete this? I have heard that Terredata has something called Regex, but after a lot of searching I can not understand it well enough.

Thanks!

You may not be looking for exactly the same, but if you want to have 1 only when there is a positive goal and no negative target, why not create it if there is a negative target and 1 is otherwise? For example, for example,

  case when target_region is like '% targ =!%', then 0 when targeting_ state '% targ =%' then 1 more tap - Optional If you are not present in the targeting area as target_ flag    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -