Getting the "latest" related record from a SQL DB

Gianni Ceccarelli dakkar at
Thu Oct 9 17:48:35 BST 2014

I think you want a window function (see for example )

Something like:

  SELECT name,title
  FROM (
   SELECT,album.title,rank() OVER (
   ) as r
   FROM artist
   JOIN album ON = album.artist_id
  ) x
  where r=1;

(tested in Postgres)

	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88

Abracadaver: Now you meet your doom!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
Url :

More information about the mailing list