From: Chris Bitmead <chris.bitmead@bigfoot.com>
To: pgsql-sql@hub.org
Subject: Slashdot Query
Date: Fri, 04 Jun 1999 13:18:53 +1000
Message-ID: <3757459C.F0E63B5E@bigfoot.com> (raw)
References: <001801beae2c$354dd580$0b8c5aa5@timnt.weather.net>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: chris.bitmead@bigfoot.com, pgsql-sql@hub.org
Subject: Re: Slashdot Query
In-Reply-To: <3757459C.F0E63B5E@bigfoot.com>
References: <001801beae2c$354dd580$0b8c5aa5@timnt.weather.net> <3757459C.F0E63B5E@bigfoot.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox