BS_THE_ANALYST
Databricks Partner

Nice solutions! @ManojkMohan @WiliamRosa 

I love the use of the temp view for the intermediate result. The array_contains is also a really nice touch. 

@ManojkMohan when you write "SET VARIABLE ids = ARRAY('12483258','12483871','12483883');" ... can this array be from another query to make it dynamic? 

Really cool stuff. 

@zc I guess we could also use parameters: https://docs.databricks.com/aws/en/sql/user/queries/query-parameters#query-based-dropdown-list . The benefit of this is that the query can be maintained/updated outside of the script, given that you used a query based drop down list parameter. I haven't tried it but it makes sense, in theory. Example of using a parameter below:

BS_THE_ANALYST_0-1755952877629.png

All the best,
BS