I currently have a stored procedure that returns a list of account numbers and associated details. The result set may contain multiple entries for the same account number. I also want to get some aggregate information such as how many distinct accounts are contained within a particular result set. Is there some way to retrieve such a view from my stored procedure results such as
SELECT AccountNumber, Count(*)
FROM mystoredproc_sp
GROUP BY AccountNumber
It's fine if it needs to be contained within another stored procedure, but I'd like to be able to at least benefit from the logic that already exists in the first SP without duplicating the bulk of its code.