problem with distinct rows

From: tony <tony(at)tgds(dot)net>
To: postgres list <pgsql-general(at)postgresql(dot)org>
Subject: problem with distinct rows
Date: 2005-03-08 09:03:48
Message-ID: 1110272629.3566.22.camel@hush
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I am having a problem with returning distinct rows this is probably a
newbie question but here goes:

Tables are artist, created_by and works
the join is on created_by.work_id and created_by.artist_id

A work of art can have two or more artists listed as creators in created
by. In the inventory lists we don't care we only need one reference to
each work AND (this is the part that hurts) they must be ordered
alphabetically by the _first_ artists name.

example:
artist_name : title : inventory_number
Bernadette Genée et Alain Le Borgne : Pièce à conviction : 004090101

Should be after "F" and before "H"

But if I do DISTINCT ON inventory_number I must order by
inventory_number then artist_name which totally defeats my purpose. I
have also played with GROUP BY and HAVING which

Clues much appreciated

Tony Grant

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephane Bortzmeyer 2005-03-08 09:29:49 Re: [Auth] 'ident' method and LDAP user accounts
Previous Message Raghunath Ganti 2005-03-08 08:20:10 Postgres - Tsearch2 Module