这个 PostgreSQL 查询基本上显示了 12 小时之前的数据列表。
SELECT * FROM listing_websites
WHERE ( ( NOW() - last_visited ) > INTERVAL '12 hour' OR last_visited IS NULL )
GROUP BY url,pkey ORDER by pkey ASC
显示的数据将如下所示。pkey 是“主键”
pkey | url | last_visited
12 | link1 | 2012-11-08 17:06:49.553515
13 | link2 | 2012-11-07 05:36:55.270243
14 | link1 | 2012-11-09 08:54:33.51958
15 | link3 | 2012-11-03 16:29:17.20889
17 | link1 | 2012-11-08 05:54:33.51958
我想要实现的是对 url 列进行分组,例如:
pkey | url | last_visited
12 | link1 | 2012-11-08 17:06:49.553515
13 | link2 | 2012-11-07 05:36:55.270243
15 | link3 | 2012-11-03 16:29:17.20889
提前感谢谁能解决这个问题。无论如何,我仍在学习 postgresql,尤其是在 GROUP BY 函数中。TIA