I am trying to select nested comments from a table with this structure
CREATE TABLE picture_comments
(
comment_id serial NOT NULL,
user_id integer NOT NULL,
"comment" text NOT NULL DEFAULT ''::text,
comment_date timestamp without time zone NOT NULL DEFAULT now(),
I am trying to write a query that selects recent submissions (sorted by
submission_date) but only selects the most recent one for each user_id.
example query: /select distinct on (user_id) * from stories order by
date_submitted desc limit 10;/
However postgres will not allow me to filter out
On 11/5/2011 12:49 PM, Tom Lane wrote:
Cstdenis writes:
I am trying to write a query that selects recent submissions (sorted by
submission_date) but only selects the most recent one for each user_id.
example query: /select distinct on (user_id) * from stories order by
date_submitted desc limit
On 11/5/2011 4:11 PM, Tom Lane wrote:
Cstdenis writes:
If I understand that you are proposing as
select * from
(select distinct on (user_id) * from stories as s order
by user_id) as foo
order by date_submitted desc limit 10;
No, you always need to sort by