I am using possql through the DataGrip program. I have the following table:
timestamp | Channel | media
-----------------------------------------
2020-04-29 00:00:00 | 3 | 1.2
2020-04-29 00:00:00 | 4 | 2
2020-04-29 00:00:00 | 5 | 1
2020-04-29 00:10:00 | 3 | 2
2020-04-29 00:10:00 | 4 | 1.5
2020-04-29 00:10:00 | 5 | 3
I would like to sort by the highest value in the "media" column for each "timestamp", as follows:
timestamp | Channel | media
-----------------------------------------
2020-04-29 00:00:00 | 4 | 2
2020-04-29 00:10:00 | 5 | 3
How can I do this?
I tried to do this but it didn't work, it's repeating the original table:
SELECT timestamp, max(media), channel
FROM monitoring_aggregate
GROUP BY timestamp, channel
ORDER BY timestamp