left outer join only select newest record - Mailing list pgsql-sql

From Gary Stainburn
Subject left outer join only select newest record
Date
Msg-id 201205231027.39198.gary.stainburn@ringways.co.uk
Whole thread Raw
Responses Re: left outer join only select newest record  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-sql
Hi folks,

I know I've seen posts like this before but Google isn't helping today.

I have two tables, vehicle stock and tax requests. Each vehicle can be taxed 
more than once, but I only want to pull in the most recent tax request - the 
one with the highest ud_id.

I have the following, which obviously returning multiple records which then 
appears that the same vehicle is in stock multiple times.  How can I make it 
so we only show each vehicle once, showing the most recent tax request 
details.


select * from stock_details s
left outer join used_diary u on s.s_registration = u.ud_registration;


-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 


pgsql-sql by date:

Previous
From: Ferruccio Zamuner
Date:
Subject: sub query and AS
Next
From: "Oliveiros d'Azevedo Cristina"
Date:
Subject: Re: left outer join only select newest record