What is the best or most efficient way to get multiple aggregate result values?
Basically I have an email app and wanted to get all the numbers of messages for each type of folder (inbox, sent, archived, flagged... ) as defined below.
Here is a sample of things I am trying to do in one stored proc call. (where [uid] is the userID)
SELECT * FROM Message
Inbox WHERE [to] = [uid]
Unread WHERE [to] = [uid] and isread = 0
Flagged WHERE [to] = [uid] and isFlagged = 1
Drafts WHERE [to] = [uid] and isDraft = 1
Sent Messages WHERE [from] = [uid]
Archived Messages WHERE [to] = [uid] and isArchived = 1