• Your options are either to limit the selections the manager has and run a specific stored procedure for each option, return the all the detail data and do all the manipulation and roll up in your application, or do a single stored procedure that uses dynamic sql that returns the data as desired. The downside to the third option is that you need to be sure to protect against SQL Injection. Here are a couple of links to articles acknowledged to be some of the best about dynamic sql.

    http://www.sommarskog.se/dynamic_sql.html

    http://www.sommarskog.se/dyn-search-2005.html