Providing a True/False(Y/N) if text in a comma separated string is in a separate column

Hello,

 

I have data that looks like this and the goal is to validate if the order season is in the selling season.  I tried like but it didn't seem to be consistent.   Any help would be appreciated.

Order SeasonSelling SeasonsGoal
18SP18SP,18SU,18FA,19SPY
19FA18SP,18SU,18FA,19SPN
18FA18SP,18SU,18FA,19SPY
20SP18SP,18SU,18FA,19SPN

 

Thank you,

 

DMJerry

Best Answer

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    Do you have an example of your like statement or how it wasn't consistent?

     

    Like should work to determine if the order season is in your selling season CSV string.

     

    CASE
    WHEN `Selling Seasons` like CONCAT('%', `Order Season`, '%') THEN
    'Y'
    ELSE
    'N'
    END
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**

Answers

  • GrantSmith
    GrantSmith Coach
    Answer ✓

    Do you have an example of your like statement or how it wasn't consistent?

     

    Like should work to determine if the order season is in your selling season CSV string.

     

    CASE
    WHEN `Selling Seasons` like CONCAT('%', `Order Season`, '%') THEN
    'Y'
    ELSE
    'N'
    END
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Thank you!  The concat was the key that I missed.  Appreciate it sir!