It's a matter of logic and knowledge of PostgreSQL features. I have the following query result:
I need to do a filtering, grouping by [hour] so that only the closest [real_time] remains, and consequently the whole corresponding line (I have a series of other columns).
I started trying to solve by calculating the absolute value of the difference in seconds. However, by grouping by hour and calculating the minimum value of the [dif_abs] column, how do you ensure that the other values in the corresponding row remain? Since I can not use an aggregator, it might not match in some cases.