Richard Albright <ralbri...@insiderscore.com> writes:
> you could use distinct on
>
> select distinct on (fs.film.title, fs.film.year ) title, year
> from fs.film left join fs.star on fs.film.id = fs.star.film
>   where fs.star.last = 'Sheen';

Thanks, I didn't know about "distinct on".  This version uses the
primary (surrogage) key:

select distinct on (fs.film.id) fs.film.title, fs.film.year
  from fs.film left join fs.star on fs.film.id = fs.star.film
  where fs.star.last = 'Sheen';

DES
-- 
Dag-Erling Smørgrav - d...@des.no

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to