Re: tricky GROUP BY / JOIN question

From: T E Schmitz <mailreg(at)numerixtechnology(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: tricky GROUP BY / JOIN question
Date: 2004-11-09 14:46:02
Message-ID: 4190D82A.6040102@numerixtechnology.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello Tom,

Tom Lane wrote:

> T E Schmitz <mailreg(at)numerixtechnology(dot)de> writes:
>
>>This is *almost* what I need:
>
>
>>SELECT
>>BRAND.BRAND_NAME,
>>MODEL.MODEL_NAME,
>>min (ITEM.PRICE),max (ITEM.PRICE)
>>*min (CONDITION.POSITION),max (CONDITION.POSITION)*
>>FROM ITEM
>>left outer join MODEL on MODEL_PK =ITEM.MODEL_FK
>>left outer join BRAND on BRAND.BRAND_PK =MODEL.BRAND_FK
>>left outer join CONDITION on CONDITION.CONDITION_PK = ITEM.CONDITION_FK
>>group by BRAND.BRAND_NAME,MODEL.MODEL_NAME
>
>
>>In the result I don't want min/max(POSITION) but CONDITION.NAME of min
>>and max(POSITION) for each MODEL.
>
>
> <snip>
> (select name from condition c1 where position = min(condition.position)),
> (select name from condition c2 where position = max(condition.position)),
> <snip>

Thank you, Tom, this worked a treat!

--

Regards/Gruß,

Tarlika Elisabeth Schmitz

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrei Bintintan 2004-11-09 14:58:27 upper/lower for german characters
Previous Message Giulio Orsero 2004-11-09 14:40:39 Drop all indexes of a table w/o knowing the index names