Skip to content
Advertisement

min of substring across many rows- exclude blank and take the least value

I have a sample data here: What I need is for each product_id, the least number is each level

Expected result

But as I have multiple rows for the same product id, it selects blank over 184 in level 4

Click here for example dataset- Product in different levels

Advertisement

Answer

You can use case when you aggregate to filter out the 0 values:

Note: You could also write the condition as when level_2 <> ''.

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