Skip to content
Advertisement

SQL/Presto: how to choose rows if the values match with another table’s

I have 2 tables:

table 1:

table 2:

I want to add a column for table 2 such that if cnt in table1 for a task is the same as cnt2 for a task in table2. If there is no match, mark it as ‘no match’

desired result:

I started from a query like the one below to pick tasks that have matched values

but I got an error for the where part.

Advertisement

Answer

Use left join and case expression to calculate matched:

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