• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Group by Id with greatest value

Resolved: Group by Id with greatest value

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a simple table where I’m calculating a “level value” dynamically via SELECT with repeated Ids in this table, what I’m trying to do is to Group the rows Ids by the greatest level value.
Fiddle: https://www.db-fiddle.com/f/2Pyfi2PMV8eaQbDt2uWQjc/2
I already tried using CASE in Group and Order but does not work well.
I already tried using MAX() but I get the score of the second value instead of the fourth. What I’m trying to get is a result like:
Is there any way to group the Ids but in case there’s a repeated Id get the one with the greatest level?
Thanks.

Answer:

You can use group by like this :
and the result is :

If you have better answer, please add a comment about this, thank you!

database group mysql sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Resolved: Table data is coming as empty in React

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.