Re: Select last there dates - Mailing list pgsql-novice

From David Gardner
Subject Re: Select last there dates
Date
Msg-id 467A8189.2050309@gardnerit.net
Whole thread Raw
In response to Select last there dates  ("Loredana Curugiu" <loredana.curugiu@gmail.com>)
List pgsql-novice
I'm not sure about getting all the dates into a single comma separated
field, if table two had a unique id field, say table2.id then  this
should retrieve the last three dates per phone number:

SELECT table1.uid, table1.phone_number, table2.id, table2.date
FROM table1 JOIN table2 ON table1.uid=table2.uid
AND table1.phone_number=table2.phone_number
WHERE table1.uid = 8
AND (table2.id IN
(SELECT id FROM table2
WHERE table2.phone_number = table1.phone_number
ORDER BY table2.date DESC LIMIT 3 ));


--
David Gardner

pgsql-novice by date:

Previous
From: "Loredana Curugiu"
Date:
Subject: Re: [SQL] Select last there dates
Next
From: "Andrej Ricnik-Bay"
Date:
Subject: Re: stem override, tsearch2