Using WSS 3.0 I have recently figured out how to aggregate the announcements from several Sharepoint sub-site so that they can be displayed on the top-level site (See: Sharepoint - How to agregate Announcements from sub-sites onto main site).
What I need to do now is to display just the most recent announcement from each of the sub-sites - rather like the SELECT TOP 1 FROM that you might have in SQL. So although each of the sub-site might have several Announcements, I only want to display the most recent one from each of them.
I assumed that this was going to be dead easy - it seems to an obvious sort of thing to want to do, but I just can't find any reference in the docs that I have.
So if anyone knows how to do this, or can point me in the right direction, that would be great.
Thanks.
This is not possible without custom code (be it XSL or C#). You can do a grouping by WebId when using SPSiteDataQuery (COntextQueryWebPart) and CAML, but you cannot do a top INSIDE the grouping. YOu could try to do each site seperately and set the CAML query's RowLimit to 1 and OrderBy to Created, using ASCENDING='False'
SO the query would look something like this:
<View>
<ViewFields>
....
</ViewFields>
<Query>
<Where>
....
</Where>
<OrderBy>
<FieldRef Name='Created' Ascending='False' />
</OrderBy>
</Query>
<RowLimit>1</RowLimit>
</View>