It's definitely possible. A fairly simple INNER JOIN should do it:DECLARE @UserID INTSET @UserID = 1202SELECT FID, COUNT(NID) FROM NoteStorage WHERE UID = @UserIDGROUP BY FID
The above code returns the FolderID and number of notes inside it for a particular user. To get the folder names use an INNER JOIN to the Folders table:SELECT FID, [Text], COUNT(NID) AS NumberOfNotes FROM NoteStorage INNER JOIN FoldersON NoteStorage.FID = Folders.[ID]WHERE UID = @UserIDGROUP BY FID, [Text]
You should try to avoid using keywords such as text, id, etc for column or table names since they have to be "escaped" using brackets, which can be quite a pain if you have to do it over and over again
Read the Books Online for more information.OS