Skip to content

Instantly share code, notes, and snippets.

@AshishKapoor
Created September 22, 2022 06:34
Show Gist options
  • Save AshishKapoor/2c5e489b8f009af4e1e7f85b99384f5e to your computer and use it in GitHub Desktop.
Save AshishKapoor/2c5e489b8f009af4e1e7f85b99384f5e to your computer and use it in GitHub Desktop.
SELECT DATE_TRUNC('day', time) AS __timestamp,
fill_level AS fill_level,
sensor_id AS sensor_id,
AVG(sensor_id) AS "AVG(sensor_id)"
FROM demo.pg_fill_measurements
GROUP BY fill_level,
sensor_id,
DATE_TRUNC('day', time)
ORDER BY "AVG(sensor_id)" DESC
LIMIT 10000;
@AshishKapoor
Copy link
Author

This is for a simple pg table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment