Re: challenging query

From: Haller Christoph <ch(at)rodos(dot)fzk(dot)de>
To: c(dot)ruffin(at)ieee(dot)org (Chris Ruffin)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: challenging query
Date: 2001-10-05 17:03:41
Message-ID: 200110051503.RAA01444@rodos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> 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?
>
Now that I've read your request more attentively, I understand what
you want. But I have to admit I have no idea how to word the query,
I even don't know if it's possible at all.
Regards, Christoph

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-10-05 18:49:01 Re: [SQL] Why the weak key is created as unique
Previous Message Tomasz Myrta 2001-10-05 15:17:56 Re: temporary views