Re: [GENERAL] problem with distinct rows

2005-03-08 Thread tony
Le mardi 08 mars 2005 à 12:29 +0100, Martijn van Oosterhout a écrit : > and, does it work? Obviously you need to put the joins in and such. But > the outer query should be last, like: > > SELECT * FROM > (... subquery ...) AS x > ORDER BY name; > > The outer query is only for ordering, the joi

Re: [GENERAL] problem with distinct rows

2005-03-08 Thread Martijn van Oosterhout
On Tue, Mar 08, 2005 at 12:22:35PM +0100, tony wrote: > Le mardi 08 mars 2005 à 11:04 +0100, Martijn van Oosterhout a écrit : > > You can put the DISTINCT ON() query as a subquery, and an ORDER BY in > > the outer query. > > That was my first guess > > select number.inventorynumber, name, first_n

Re: [GENERAL] problem with distinct rows

2005-03-08 Thread tony
Le mardi 08 mars 2005 à 11:04 +0100, Martijn van Oosterhout a écrit : > You can put the DISTINCT ON() query as a subquery, and an ORDER BY in > the outer query. That was my first guess select number.inventorynumber, name, first_name from (select distinct on (inventorynumber) inventorynumber from

Re: [GENERAL] problem with distinct rows

2005-03-08 Thread John Sidney-Woollett
Add a SORTNAME field to the artist table and use that for sorting. This will help you deal with diacrtics and accented characters by transposing them to a regular character instead. The sortname value for Genée would be "genee". With a few changes to your data model (and possibly application) yo

Re: [GENERAL] problem with distinct rows

2005-03-08 Thread Martijn van Oosterhout
You can put the DISTINCT ON() query as a subquery, and an ORDER BY in the outer query. Sorting by surname is tricky since you need to tell the computer how to find it... Hope this helps, On Tue, Mar 08, 2005 at 10:03:48AM +0100, tony wrote: > Hello, > > I am having a problem with returning dist

Re: [GENERAL] problem with distinct rows

2005-03-08 Thread John Sidney-Woollett
If the created_by table includes an artist number/position to indicate the first, second artist etc, eg create table created_by ( work_id integer, artist_id integer, position integer, primary key (work_id, artist_id, position) ); then you can simply use the following query select a.ar