I've been asked to design a report that provides salespersons' sales by the current month, the current calendar year's first, second, and third quarters, and the current year-to-date. Here's an example:
Salesperson: ABC
-------------------- Current Calendar Year -------------------
Product Current Month First Quarter Second Quarter Third Quarter Fourth Quarter Year-to-Date
==================================================================
Product 01 $100.00 $5,000.00 $9,000.00 $1,000.00 $100.00 $15,200.00
Product 02 $12,000.00 $2,000.00 $14,000.00
Product 03 $3,000.00 $1,000.00 $4,000.00
Product 04 $200.00 $4,000.00 $6,000.00 $2,000.00 $300.00 $12,500.00
Product 05 $3,200.00 $5,000.00 $3,000.00 $11,200.00
Product 06 $7,100.00 $8,000.00 $2,000.00 $500.00 $17,600.00
Product 07 $2,000.00 $1,000.00 $3,000.00
Product 08 $4,000.00 $1,000.00 $5,000.00
Product 09 $350.00 $15,000.00 $1,000.00 $16,350.00
Product 10 $1,750.00 $7,000.00 $2,000.00 $1,000.00 $11,750.00
---------------------------------------------------------------------------------------------------------
TOTALS $650.00 $50,050.00 $45,000.00 $13,000.00 $1,900.00 $110,600.00
There are perhaps hundreds of products; however, only the products for which the selected salesperson has sales should appear on the report. For example, Salesperson ABC has sales for only ten of the hundreds of products; therefore, only those ten products
are displayed.
The challenge, as I see it, is that the result set (i.e., the rows) for each sales column could be unique (and are unique, in this example); e.g., for the "Current Month" column, this salesperson had sales only for Products 01, 04, and 09, yet for
the "Second Quarter" column, they had sales for all products *except* Product 09 -- regardless, a common result set needs to be generated so that results for all ten products are accounted for, for each of the columns.
How can I go about writing the query/queries that will return these results in SSRS?
I was thinking of writing a query that returns all of the products for the selected salesperson, for the year-to-date. Then this result set could perhaps be used as an outer join for each column's results. Thoughts? Would this be a candidate for a stored procedure?