Search Postgresql Archives

problem with distinct rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux