I would like to select the row that caontains the max value on a column (rank) with specific conditions : 1 : result > 0 2 : apply = 17
this is my sql select
SELECT *
FROM mytable
WHERE apply = 17 and result > 0
HAVING MAX(rank)
In this exapmle i should have as output the row with id 11
CodePudding user response:
You are not aggregating here so having is not correct; you want a single row based on an order (by rank) so
SELECT *
FROM mytable
WHERE apply = 17 and result > 0
ORDER BY rank DESC
LIMIT 1;