Displaying items in a table according to the earliest date found in a column

From: <nathan.cutmore_at_burohappold.com>
Date: 21 Jan 2005 08:07:01 -0800
Message-ID: <1106323620.992954.68600_at_z14g2000cwz.googlegroups.com>



Hello again

I am trying to develop an SQL query that turns this table...



item_id item_title location_id location dueback
476         Abfab          2               Dubai        01/04/05
476         Abfab          6               London       23/07/05
476         Abfab          6               London       17/08/05
476         Abfab          6               London       20/08/05
476         Abfab          3               Paris        12/05/05

----------------------------------------------------------------
(Note: This table shows that there are 3 copies of this item located at London and 1 each in Dubai and Paris. Item_id and item_title will always be the same. Location_id and location are related to eachother. There are up to 10 different locations so I do not want to hard code the location names.
The columns are ordered by 'ORDER BY location, dueback ASC')

Into this (where each location is shown but only with the row that has earliest 'dueback' date) ...



item_id item_title location_id location dueback
476         Abfab          2               Dubai        01/04/05
476         Abfab          6               London       23/07/05
476         Abfab          3               Paris        12/05/05


----------------------------------------------------------------
I'd like to do this with an SQL query which I can use in a stored procedure without adding to the code-behind. Any ideas welcome? Received on Fri Jan 21 2005 - 17:07:01 CET

Original text of this message