From: Rodrigo De León <rdeleonp@gmail.com>
To: Jamie Tufnell <diesql@googlemail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Having difficulty writing a "best-fit" query..
Date: Tue, 16 Oct 2007 12:11:16 -0500
Message-ID: <a55915760710161011g6f67bbdege536dc3f8ac22342@mail.gmail.com> (raw)
In-Reply-To: <b0a4f3350710160946y4a31a227sbffbf085cdbfa487@mail.gmail.com>
References: <b0a4f3350710160946y4a31a227sbffbf085cdbfa487@mail.gmail.com>
On 10/16/07, Jamie Tufnell <diesql@googlemail.com> wrote:
> I'm taking a subset of all my genres, and I want to get ONE row for each
> movie in the subset alongside its most appropriate genre (whichever has the
> highest relevance). In other words, the best fit.
You didn't provide the expected output, but try:
SELECT *
FROM t tt
WHERE relevance = (SELECT MAX(relevance)
FROM t
WHERE movie_id = tt.movie_id)
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rdeleonp@gmail.com, diesql@googlemail.com
Subject: Re: Having difficulty writing a "best-fit" query..
In-Reply-To: <a55915760710161011g6f67bbdege536dc3f8ac22342@mail.gmail.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