I have a result set that looks like this:
ID | name | myvalue 1 | A1 | 22 2 | A2 | 22 3 | A3 | 21 4 | A4 | 33 5 | A5 | 33 6 | A6 | 10 7 | A7 | 10 8 | A8 | 10 9 | A9 | 5
what I want is to include only lines that contain the highest available "myvalue" (in the previous example - 33), and then:
ID | name | myvalue 4 | A4 | 33 5 | A5 | 33
The IE request should select the highest available "myvalue" (IE 33), and it should remove the lines that have myvalue <33
SELECT ..... WHERE myvalue = THE_HIGHEST_OF(myvalue)
In the hope that it was clear ...
early
edit:
my current request
SELECT *, (very long code that returns a integer as relevance score) AS myvalue FROM mytable HAVING myvalue = ????? ORDER BY myvalue DESC
now the highest value of myvalue can be 10, 20, 30, any number ... in the final result set I want to include only the rows that have the highest possible relevance score
ive tried using GROUP BY, but I always need to repeat ...
(very long code that returns a integer as relevance score) AS myvalue
... twice
source share