I have the following nested data in two columns:
Categories_A Categories_B
{"A"} {"B","F","C"}
{"B","A"} {"Z","B","F"}
{"B","F"} {"A","E","R"}
I would like to return in a new column the missing category/categories in categories_B when compared to categories_A - what is in Categories_A that is not in categories_B. So ideally:
Categories_A Categories_B Missing_Category
{"A"} {"B","F","C"} {"A"}
{"B","A"} {"Z","B","F"} {"A"}
{"B","F"} {"A","E","R"} {"B","F"}
So far what I managed is to return if there is a complete match between the columns:
select Categories_A, Categories_B,
case
when Categories_A = Categories_B then 'TRUE'
else 'FALSE'
end is_a_match
from facts_themes
Categories_A Categories_B is_a_match
{"A"} {"B","F","C"} FALSE
{"B","A"} {"Z","B","F"} FALSE
{"B","F"} {"A","E","R"} FALSE