From: Haller Christoph <ch@rodos.fzk.de>
To: c.ruffin@ieee.org
Cc: pgsql-sql@postgresql.org
Subject: Re: challenging query
Date: Fri, 05 Oct 2001 11:48:57 METDST
Message-ID: <200110050948.LAA01172@rodos> (raw)
In-Reply-To: <579d73bf.0110030933.22b6d76e@posting.google.com>
>
> Consider the following table:
>
> A B C D select?
> -------------------------------
> 1 FOO A1 100 n
> 1 BAR Z2 100 n
> 2 FOO A1 101 y
> 2 BAR Z2 101 y
> 3 FOO A1 102 y
> 4 BAR Z2 99 y
> 5 FOO A1 99 n
> 6 BAR Z2 98 n
> 7 FOO AB 103 y
> 7 BAR ZY 103 y
>
> This table has the idea of "groups", that is, a group is defined as
> all of the words from B that have the same number A. The values in
> column C also matter- we want to select both groups A=7 and A=1 since
> they contain different values C. Note that the groups defined by A=1
> and A=3 are distinct- they do not contain the same number of words
> from B, so we want to select them both. Also note that D is datetime,
> and all the rows with the same number A will have the same D (this is
> actually ensured by a single row in another table.)
>
> I want to select all of the numbers A which define distinct groups and
> have the highest datetime D. Is this possible in a SQL query?
Sorry, there is an inconsistency in your question, at least to me.
In the table's last column you say you want to select
A in (2,3,4,7)
but in the epilogue you say you want to select
A in (7,1,1,3)
What did I miss?
Regards, Christoph
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: ch@rodos.fzk.de, c.ruffin@ieee.org
Subject: Re: challenging query
In-Reply-To: <200110050948.LAA01172@rodos>
* 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