All pastes #547384 Raw Edit

Someone

public text v1 · immutable
·published 2007-06-07 11:17 UTC
rendered paste body
webstats=> select ip1 as IP, fecha as date, hora as time from stats order by date desc, time desc limit 30;

       ip       |    date    |   time   
----------------+------------+----------
 201.140.77.84  | 2007-06-04 | 18:16:14
 201.140.77.84  | 2007-06-04 | 18:16:14
 201.140.77.84  | 2007-06-04 | 18:16:14
 201.140.77.84  | 2007-06-04 | 18:16:14
 201.140.77.84  | 2007-06-04 | 18:16:14
 201.140.77.84  | 2007-06-04 | 18:16:14
 201.140.77.84  | 2007-06-04 | 18:16:13
 201.140.77.84  | 2007-06-04 | 18:16:13
 201.140.77.84  | 2007-06-04 | 18:16:13
 201.140.77.84  | 2007-06-04 | 18:16:12
 74.6.17.45     | 2007-06-04 | 18:15:28
 74.6.18.19     | 2007-06-04 | 18:01:38
 74.6.17.40     | 2007-06-04 | 18:00:48
 74.6.17.154    | 2007-06-04 | 18:00:25
 74.6.17.142    | 2007-06-04 | 17:54:43
 74.6.17.45     | 2007-06-04 | 17:53:42
 201.229.252.5  | 2007-06-04 | 17:51:25
 201.229.252.5  | 2007-06-04 | 17:51:25
 201.229.252.5  | 2007-06-04 | 17:51:25
 201.229.252.5  | 2007-06-04 | 17:51:25
 201.229.252.5  | 2007-06-04 | 17:51:24
 201.229.252.5  | 2007-06-04 | 17:51:24
 201.229.252.5  | 2007-06-04 | 17:51:23
 201.229.252.5  | 2007-06-04 | 17:51:23
 201.229.252.5  | 2007-06-04 | 17:51:23
 201.229.252.5  | 2007-06-04 | 17:51:21
 74.6.18.35     | 2007-06-04 | 17:44:16
 74.6.17.41     | 2007-06-04 | 17:43:11
 87.217.173.250 | 2007-06-04 | 17:31:47
 87.217.173.250 | 2007-06-04 | 17:31:46
(30 rows)



****
I would like to obtain something like:
(This is: the last 8 IPs that are listed, and if any IP appears appears several times in a row, the date and time returned is the older)
****


       ip       |    date    |   time   
----------------+------------+----------
 201.140.77.84  | 2007-06-04 | 18:16:12
 74.6.18.19     | 2007-06-04 | 18:01:38
 74.6.17.40     | 2007-06-04 | 18:00:48
 74.6.17.154    | 2007-06-04 | 18:00:25
 74.6.17.142    | 2007-06-04 | 17:54:43
 74.6.17.45     | 2007-06-04 | 17:53:42
 201.229.252.5  | 2007-06-04 | 17:51:21
 74.6.18.35     | 2007-06-04 | 17:44:16
(30 rows)