|  | Posted by Anthony Paul on 04/20/07 14:07 
Hello Robert,
 That wouldn't work since it groups by location_id and would return the
 following :
 
 location_id date_created
 =========== ============
 5           2000-01-01 01:05
 2           2000-01-01 01:07
 7           2000-01-01 01:08
 
 I am looking into Mark's solution as we speak...
 
 Regards,
 
 Anthony
 
 On Apr 20, 9:59 am, Robert Klemme <shortcut...@googlemail.com> wrote:
 > On 20.04.2007 15:49, markc...@hotmail.com wrote:
 >
 > > If you are using SQL Server 2005, you can do this
 >
 > > with cte(location_id,date_created,grp)
 > > as (
 > > select location_id,
 > >        date_created,
 > >        rank() over(partition by location_id order by date_created)
 > >        - rank() over(order by date_created)
 > > from mytable)
 > > select location_id,
 > >        max(date_created) as date_created
 > > from cte
 > > group by location_id,grp
 > > order by max(date_created)
 >
 > I'd do
 >
 > select location_id, max(date_created) date_created
 > from your_table
 > group by location_id
 > order by max(date_created)
 >
 > Am I missing something?
 >
 >         robert
 [Back to original message] |