Skip to content
Advertisement

Group rows with a value depending on condition of a different column SQL

I have a list of rows that I need to group by a key and for each group the value of two columns depends on a condition from a different column.

For example enter image description here

should become enter image description here

That means, for the value of Col 5 take the one where col 4 is the lowest and for the col 7 take the value where col 6 is the highest.

Any idea how to achieve this result?

Advertisement

Answer

This assumes that your group is determined by your key column

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