0

I have a field which contains text string, for example:

Credit for an item
Credit for menu
Debit for food
Credit for food
Debit for Delivery
Etc.

I want to categorize them into two categories impacting and none impacting adjustments

I am trying to write this expression in SQL:

If "Text_string" contain "Keywords: Food, Delivery", then "Impacting" else "None Impacting"

Thanks very much in advance

Aldwoni
  • 1,168
  • 10
  • 24
  • 1
    Is it any of those two keywords or all of them? If it is any then this is a duplicate of [**PostgreSQL wildcard LIKE for any of a list of words**](http://stackoverflow.com/q/4928054/479863). If it is all then this is a duplicate of [**Multiple LIKE and AND operators in RAILS/POSTGRESQL**](http://stackoverflow.com/q/42124181/479863). – mu is too short Feb 14 '17 at 22:07

1 Answers1

0
select  case
        when text_string ilike '%food%' and 
             text_string ilike '%delivery%' then 'Impacting'
        else 'None impacting'
        end as IsImpacting
from    YourTable
Andomar
  • 232,371
  • 49
  • 380
  • 404
  • text_string ilike '%food%' and text_string ilike '%delivery%' then 'Impacting' or text_string ilike '%food%' or text_string ilike '%delivery%' then 'Impacting' – Leo Veynberg Feb 15 '17 at 02:02