Skip to content
Advertisement

‘Tagging’ a record using multiple criteria

I am using Presto. I want to assign a row with multiple ‘tags’ using different criteria that are not mutually exclusive.

For example, let’s say there’s a table with 4 columns:

I’d like to tag each food with tags that I’ve defined, such as red food, red food on sale, yellow baked goods, yellow food on_sale ONLY. In the example, apple matches two tags:red food and red food on sale.

I can’t use CASE (like below) because I would only get back ‘red food’ when I actually want it labeled as both.

Ideally, I want to return an array that can capture more than 1 ‘tag’ or duplicate columns with one line for each tag, but I have no idea how to do that. Any ideas?

Thanks in advance!

Advertisement

Answer

You can use string concatenation:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement