I have a stored procedure that takes in two date parameters (start date, and end date). In the proc I create a temp table with three columns (description, quantity, date), and I fill that temp table with data. I fill the temp table with data by looping through the date range of what is passed in through the parameters to find the quatntity values of each product. So for example if I pass in the parameter dates of '5/1/2005', '6/30/2006' my proc will set off a loop querying the database for quantity values between the date params and fill the temp table with the product description, the quantity values, and the date that the quantity values were bought. So the temp table would end up looking something like this:
So my question is how can I trend this data so that my result set would look like below:
Is this possible with dynamic date parameters? I can do this very easily if the parameters were not dynamic. BUT I have no idea how to trend the data like the above if the date parameters are dynamic. Any suggestions would be GREATLY appreciated! Thank you for your time and sorry for the really long post.
Code:
Description Quantity Date
----------- -------- -------------------
product 1 5 May 1 2006 12:00AM
product 1 15 Jun 1 2006 12:00AM
.
.
.
So my question is how can I trend this data so that my result set would look like below:
Code:
Description May Qty Jun Qty
----------- ------- -------
product 1 5 15
product 2 13 28
.
.
.
Is this possible with dynamic date parameters? I can do this very easily if the parameters were not dynamic. BUT I have no idea how to trend the data like the above if the date parameters are dynamic. Any suggestions would be GREATLY appreciated! Thank you for your time and sorry for the really long post.