Skip to content
Advertisement

Selecting the first row of group with additional group by columns

Say I have a table with the following results:

enter image description here

How is it possible for me to select such that I only want distinct parent_ids with the min result of object0_behaviour?

Expected output:

I have tried:

It works, however if I wanted the other 2 additional columns, I am required to add into GROUP BY clause and things go back to square one.

I saw examples with R : Select the first row by group

Similar output from what I need, but I can’t seem to convert it into SQL

Advertisement

Answer

You can try using row_number() window function

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