Skip to content

Instantly share code, notes, and snippets.

@AshishKapoor
Last active September 22, 2022 07:05
Show Gist options
  • Save AshishKapoor/04bacdf0931d46fe3e09fad12a899644 to your computer and use it in GitHub Desktop.
Save AshishKapoor/04bacdf0931d46fe3e09fad12a899644 to your computer and use it in GitHub Desktop.
This one takes 55 seconds on apache superset
SELECT DATE_TRUNC('day', time) AS __timestamp,
fill_level AS fill_level,
AVG(sensor_id) AS "AVG(sensor_id)"
FROM demo.fill_measurements
JOIN
(SELECT fill_level AS fill_level__,
AVG(sensor_id) AS mme_inner__
FROM demo.fill_measurements
GROUP BY fill_level
ORDER BY mme_inner__ DESC
LIMIT 100) AS anon_1 ON fill_level = fill_level__
GROUP BY fill_level,
DATE_TRUNC('day', time)
ORDER BY "AVG(sensor_id)" DESC
LIMIT 10000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment