• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

SQL: How to get max value of a range of rows?

Red Squirrel

No Lifer
I have a bunch of rows that have a date and ping col, I want to grab the latest 288 rows, and get the max ping within that range?

You'd think this query would work, but it does not:

SELECT max(stresponse) FROM stats WHERE stshardid=31 ORDER BY stdate DESC LIMIT 288;

The max() just gets the overall max and ignores the LIMIT flag.
 
Using a subquery should allow you to get the max record from a subset of 288 records.

SELECT max(stresponse) As MaxPing FROM (SELECT columns FROM stats where stshardid=31 ORDER BY stdate DESC LIMIT 288) sub
 
Back
Top