Skip to content

Instantly share code, notes, and snippets.

@James-McNeill
Created June 26, 2021 09:32
Show Gist options
  • Save James-McNeill/5d2d05f80cb90fa316e42895b57017e0 to your computer and use it in GitHub Desktop.
Save James-McNeill/5d2d05f80cb90fa316e42895b57017e0 to your computer and use it in GitHub Desktop.
-- Using limit to select the top result
SELECT county, station, max(temp) as max_temp, min(temp) as min_temp
FROM hrly_Irish_weather
WHERE county = "Cork"
GROUP BY county, station
ORDER BY max_temp DESC
LIMIT 1;
-- Using limit to select the top result, adding an offset to start after the second line
SELECT county, station, max(temp) as max_temp, min(temp) as min_temp
FROM hrly_Irish_weather
WHERE county = "Cork"
GROUP BY county, station
ORDER BY max_temp DESC
LIMIT 1
OFFSET 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment