Re: Simpleish query I can't get my head around :)

From: Bob Badour <bbadour_at_golden.net>
Date: Fri, 26 Nov 2004 16:33:50 -0500
Message-ID: <sbudnff5Mrr5PDrcRVn-gQ_at_golden.net>


Robin Tucker wrote:

> Hi,
>
>
> Can anyone tell me how to select the "most recent" date values from a
> grouped query? Consider the following:
>
> CREATE TABLE [dbo].[TestQuery] ( [ID] [int] NOT NULL , [ID_Parent] [int] NOT
> NULL , [Date] [datetime] NOT NULL ) ON [PRIMARY]
>
> This is a simplified adjacency list. What I want to do is find the highest
> valued item by date for each sub-tree. In other words, the single highest
> date item when This.ID_Parent = That.ID_Parent. I think I first need to
> group by ID_Parent, sort by Date (descending), then select the TOP 1 from
> this query,
> but how to aggregate them so I get the TOP 1 for each ID_Parent?
>
>
> Thanks for any help you can give me,
>
> Robin

Hi Robin,

SQL sucks when it comes to quota queries. Received on Fri Nov 26 2004 - 22:33:50 CET

Original text of this message