From: | David Gardner <david(at)gardnerit(dot)net> |
---|---|
To: | Loredana Curugiu <loredana(dot)curugiu(at)gmail(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Select last there dates |
Date: | 2007-06-21 13:47:53 |
Message-ID: | 467A8189.2050309@gardnerit.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Andrej Ricnik-Bay | 2007-06-21 18:23:16 | Re: stem override, tsearch2 |
Previous Message | Loredana Curugiu | 2007-06-21 13:35:37 | Re: [SQL] Select last there dates |
From | Date | Subject | |
---|---|---|---|
Next Message | Masaru Sugawara | 2007-06-21 16:29:00 | Re: Subquery problems |
Previous Message | A. R. Van Hook | 2007-06-21 13:46:42 | join problem |