Well i cant really give a sample but i can tell you what you need to do
The best way to attack this is by using the DataSet class and a set of sql statements
each statement will collect the data for a particular category and by stacking the statements and sending them as one query you can catch each result set as a datatable within the dataset
a typical example of a statement would be something like
SELECT *,(SELECT count(*) FROM tblItems WHERE ItemCategoryID = CategoryID) as NumItems FROM tblCategories WHERE "All my conditions are met";
SELECT DISTINCT(ItemColumn), (SELECT COUNT(*) FROM tblItems AS TBL WHERE TBL.ItemColumn= tblItems.ItemColumn) as NumItems FROM tblItems;
When looping throug the datatable you could output in the following way
dim txt as string = ""
for each dr as datarow in ds.tables(0).rows
txt &= "<a href=""some.aspx?catid=" & dr("CategoryID") & """>" & dr("CatName") & " (" & dr("NumItems") & ")</a>"
next
'Add a section seperator
txt &= "<hr/>"
for each dr as datarow in ds.tables(1).rows
txt &= "<a href=""some.aspx?distinction=" & dr("ItemColumn") & """>" & dr("ItemColumn") & " (" & dr("NumItems") & ")</a>"
next