I have below example table order by Time:
I want to calculate the maximum time and minimum time for an Area.
If I use max(Time) over (partition by Area), it will get following resuls:
The problem is - for Strathfield, what I used will get the max and min time of all rows that are Strathfield.
How I want the group or partition to set up is -
Row 1-6 is a group; Row 7-11 is a group; Row 12 is a group; Row 13 is a group; Row 14 is a group; Row 15 is a group; Row 16-19 is a group; Row 20-27 is a group.
Then I can calculate the max and min time for each group.
Expected results as follow:
Is this possible in Postgresql? How do I achieve that? Thanks.