Table structure:CREATE TABLE [dbo].[ContentRepository] ( [locationID] [int] NOT NULL , [version] [int] NOT NULL , [markup] [text] COLLATE Latin1_General_CI_AS NULL , [notes] [varchar] (1000) COLLATE Latin1_General_CI_AS NULL , [editorID] [int] NOT NULL , [modified] [datetime] NOT NULL )
Sample data (ignoring fields which don't matter in query):locationID version modified ------------------------------------------------------ 1 1 2007-10-12 11:35:33.0001 6 2007-10-15 16:27:33.0001 46 2007-10-18 16:10:26.0001 47 2007-10-18 16:17:51.0001 60 2007-10-19 09:18:10.0001 61 2007-10-19 10:10:53.0002 1 2007-10-14 11:35:33.0002 4 2007-10-14 11:35:33.0002 11 2007-10-18 15:27:33.0002 12 2007-10-18 16:13:21.0003 8 2007-10-18 15:29:12.0003 9 2007-10-15 14:24:54.0004 6 2007-10-19 09:07:41.0004 7 2007-10-18 09:08:01.0005 1 2007-10-14 11:35:33.000
What I would be after is something like this:locationID version modified ------------------------------------------------------ 1 61 2007-10-19 10:10:53.0002 12 2007-10-18 16:13:21.0003 8 2007-10-18 15:29:12.0004 6 2007-10-19 09:07:41.0005 1 2007-10-14 11:35:33.000
The query I've outlined above will do this, but only if all the values in the modified column of the table are unique, which we can't guarantee.