It's nice to be able to put different types of items in a single location without having to create "category" fields or folders within document libraries to store them. But what if you need to create a webpart that needs to query a list/library for items in a specific content type? Using CAML queries can help you here.
We'll need to create a CAML query, but before we can start, we need to find our target content type id. To do this, go to your content type's settings page. Check out the query string on this page. Find ctype. This is your content type's ID.
For the purpose of this demo, I'll use a console app. When you create your query, use the element. The rest of the query is pretty basic.

My document library contains 2 documents. 1 uses the Reports content type and the other users the Documents content type. When I run the code, my results return correctly.

Now, to slightly change the code, instead of searching by content type id, let's switch over to ContentType. This will allow you to use the content type's name. You'll see that my code is going to return all items where the content type is NOT equal to Reports.
Looking at my results, you'll see that the report document correctly does not appear.
Labels: Developer