I have a table that goes as follows:
content_id | contact_count
1 23
2 4
3 89
I want to select the content_id with the highest contact_count from the last 25 rows of the table.
I’ve tried many different things such as:
select content_id from research_products_content
where contact_count=(select max(contact_count)
from research_products_content order by rating_total_id desc limit 25)
order by rating_total_id desc limit 1
In your example,
limit 25is applied after the result (max, which is a single row) is selected. Try this instead: