limit results to one row per foreign object
От | Alan Bullock |
---|---|
Тема | limit results to one row per foreign object |
Дата | |
Msg-id | e83f29$dss$1@sea.gmane.org обсуждение исходный текст |
Ответы |
Re: limit results to one row per foreign object
Re: limit results to one row per foreign object Re: limit results to one row per foreign object |
Список | pgsql-general |
hi all, I have the following schema: CREATE TABLE auctions ( id serial NOT NULL, user_id int4, title varchar(255), body varchar(255), CONSTRAINT auctions_pkey PRIMARY KEY (id) ) WITHOUT OIDS; CREATE TABLE bids ( id serial NOT NULL, auction_id int4, user_id int4, amount float8, created_at timestamp, CONSTRAINT bids_pkey PRIMARY KEY (id) ) WITHOUT OIDS; CREATE TABLE users ( id serial NOT NULL, username varchar(255), CONSTRAINT users_pkey PRIMARY KEY (id) ) WITHOUT OIDS; I'd like to return all the bids for a given auction, but limit it to only the *latest* bid from each user. so regardless of how many bids a user has placed, only their latest is returned. I dont have a clue where to even start with this and would appreciate some pointers thanks alan
В списке pgsql-general по дате отправления: