DISTINCT ON troubles
От
Jeremy Smith
Тема
DISTINCT ON troubles
Дата
Msg-id
FKEOIJEHOIKIOEHCGNCLEENEEDAA.jer@highboard.com
Ответ на
Re: Distributed Transactions (scott.marlowe)
Список
Дерево обсуждения
Distributed Transactions "George A.J" <jinujosein@yahoo.com>
Re: Distributed Transactions Josh Berkus <josh@agliodbs.com>
Re: Distributed Transactions "scott.marlowe" <scott.marlowe@ihs.com>
Re: Distributed Transactions Tom Lane <tgl@sss.pgh.pa.us>
DISTINCT ON troubles "Jeremy Smith" <jer@highboard.com>
Re: DISTINCT ON troubles Josh Berkus <josh@agliodbs.com>
Re: DISTINCT ON troubles "Jeremy Smith" <jer@highboard.com>
Re: Date / interval question Gnugeek <gnugeek@comcast.net>
Re: DISTINCT ON troubles Brian Knox <laotse@aol.net>
Re: DISTINCT ON troubles "scott.marlowe" <scott.marlowe@ihs.com>
Re: Date Foo. Brian Knox <laotse@aol.net>
Re: Date Foo. "scott.marlowe" <scott.marlowe@ihs.com>
Re: DISTINCT ON troubles "scott.marlowe" <scott.marlowe@ihs.com>
Hi, I have a query that reads: SELECT DISTINCT ON (messageboard.threadid) messageboard.threadid, messageboard.topic, owner.ownerid, owner.username FROM messageboard, owner WHERE messageboard.ownerid=owner.ownerid AND messageboard.leagueid = '$leagueid' ORDER BY messageboard.messageid DESC LIMIT $entries_on_page OFFSET $beginThread" The purpose of this query is to retrieve unique threadid's in the order of the most recent posts that have been made to each thread. When I use this query I get an error that: "SELECT DISTINCT ON expressions must match initial ORDER BY expressions". Of course, if I put ORDER BY threadid in the query it would order it in the order that the thread was created, not in the last post made. I have tried using GROUP BY threadID, I get a similar order. Am I just approaching this all wrong and need to create a temporary table and draw from that, or is there a way to salvage this query? Thanks so much, Jeremy
В списке pgsql-sql по дате отправления