Slashdot Query
От | Chris Bitmead |
---|---|
Тема | Slashdot Query |
Дата | |
Msg-id | 3757459C.F0E63B5E@bigfoot.com обсуждение исходный текст |
Ответ на | Group By Dilemma ("Tim Perdue" <perdue@raccoon.com>) |
Ответы |
Re: [SQL] Slashdot Query
|
Список | pgsql-sql |
I want to do a query that is like the icons on the top of http://slashdot.org. That is I want to select the 5 most recent distinct categories from a bunch of stories. So I have... SELECT DISTINCT category.oid, category.title, category.image FROM story, category* WHERE story.category = category.oid AND story.approved ORDER BY datetime DESC LIMIT 5; The trouble is it doesn't return distinct results, but rather it returns duplicates. Any ideas how I can do this query? I thought there might be some sub-select solution, but I don't really understand subselects. I thought of, SELECT distinct * from (SELECT category.oid, category.title, category.image FROM story, category* WHERE story.category = category.oid AND story.approved ORDER BY datetime DESC )LIMIT 5; But that doesn't work in any shape or form.
В списке pgsql-sql по дате отправления: