Is there any way to code this in snowflake?
Table 1
Based on look up table's DEPT, I want to have values like below in main table
This means, when it is SALES INTERNAL and then extra texts it should take the value of "SALES INTERNAL" as data access.
Below code produces duplicates.
ON LOWER (LTRIM(RTRIM(nvl(MainTable."DEPT", 'NA')))) ilike LOWER (LTRIM(RTRIM(nvl(LookUpTable."DEPT,'NA')))||'%')
Any help is appreciated.

