![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I have a table, which stores entries of users. Each user is identified by a unique used id. Each entry contains the userid, a timestamp and a keyword. I'm looking for a select statement, which will return a single row, which contains the very first and very last entry of all. There is no limit on the entries of user. There could be none, one, two or many. So if there are for example six entries entries from one user, I would like the select statement to return: Timestamp of First Entry, First keyword, Timestamp of Last Entry, Last Keyword Would this work: SELECT first.uid, min(first.created)::TIMESTAMP, first.keyword, min(last.created)::TIMESTAMP, last.keyword FROM userentries as first, userentries as last WHERE first.uid = last.uid GROUP BY first.keyword, last.keyword Fritz |
![]() |
| Thread Tools | |
| Display Modes | |
| |