my goal is to fetch the ingredient with the max score in the category(food) and if there two ingredients in same category with the same score fetch the one with the max point (each ingredient have a unique value from 1 to n)

r937 said:

by the way, your GROUP BY query is broken, the values that will be returned for id and title will be indeterminate and could come from any of the rows that have the max score