SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to write an equivalent CAML query for the given SQL Query below:

select top 10 * from TestTable where ItemID in ( select top 10 ItemID from TestTable order by Views desc) order by UserName desc;

How do I do this?

share|improve this question
up vote 2 down vote accepted

Check out U2U CAML Query Builder, it'll help you build any number of CAML Query possibilities that you need.

share|improve this answer
But I do not see any option to get the top 10 items... – Karthikeyan Dec 21 '10 at 14:42
You need to use the RowLimit tag. – James Love Dec 21 '10 at 15:04
Sorry, I am not able to make such a CAML query, any help – Karthikeyan Dec 21 '10 at 16:57
Just bang a <RowLimit>10<RowLimit> in your query somewhere inside <View></View> – James Love Dec 21 '10 at 17:40
i agree, rowcount works perfectly however it does not to make a sub query ... – Karthikeyan Dec 21 '10 at 20:16

Your Answer


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.