Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to get the elements with the most new created date using CAML query in sharepoint 2007.

I can do it using:

"<OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy><RowLimit>1</RowLimit>"

To get the most recent date and then use other CAML query to get the elements with that date.

But, theres no other way to do it in one consult?

share|improve this question
    
What's your issue? You just add a ViewFields node to get the fields you want. –  James Love Feb 18 '11 at 16:41
add comment

1 Answer

As far as I can tell, you're trying to do the SQL equivalent of a self join: Querying the maximum date in a subquery and joining back to the table on that date.

Unfortunately CAML doesn't allow you to do self joins; I'm afraid there is no way to do this in a single query.

share|improve this answer
1  
Related - You can use SPList.LastModified to get the last time an item was created or modified - but no way to tell if this date was from a creation or update without further checking. msdn.microsoft.com/en-us/library/… –  Ryan Jul 21 '11 at 12:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.