How to SELECT last row of every hour? I have a table (in database) with one minute data in each row.
Like this:

Date_time            Value

2018-11-01 10:58:00  189.0
2018-11-01 10:59:00  189.0
2018-11-01 11:00:00  189.19
2018-11-01 11:01:00  189.19
2018-11-01 11:02:00  189.35
...
2018-11-02 13:57:00  192.38
2018-11-02 13:58:00  192.41
2018-11-02 14:01:00  192.35
2018-11-02 14:02:00  192.35
...
2018-11-06 15:50:00  196.89
2018-11-06 15:51:00  196.86
2018-11-06 16:00:00  196.77
2018-11-06 16:01:00  196.69
2018-11-06 16:02:00  196.64


I need to SELECT last row of every hour in table. The difficulty here is that it is not known what minute will be the last in an hour.
According to:

 https://www.sqlite.org/windowfunctions.html


SQLite supports window functions. You can therefore easily enumerate the resultset like:

SELECT date_time, value
     , row_number() over (partition by DATE(date_time), HOUR(date_time)
                          order by dt desc) as rn
FROM T


I'm not sure what date functions there are, so you might have to change those. Now, since we ordered them in descending order, we can just pick the first one:

SELECT date_time, value
FROM (
    SELECT date_time, value
         , row_number() over (partition by DATE(date_time), HOUR(date_time)
                              order by dt desc) as rn
    FROM T
) AS X
WHERE rn = 1;