Link to home
Start Free TrialLog in
Avatar of RUA Volunteer2?
RUA Volunteer2?Flag for United States of America

asked on

How to create a pivot table in SQL SERVER with a Dynamic Date Range passed into it that builds columns

I have a SQL query that I cannot post so I am looking for an example or direction if you can help please. We have a dataset / datasource that has month over month to year over year data. We need to be able to allow a user to pick a date range and the SQL build a Pivot Table that dynamically builds the Pivot table based on their selection. I heard rumor that this might be possible with a variable driven by parameters? Can any one describe demonstrate point to video/illustrate or have all 3 pieces of information that might help me accomplish this.

So the user picks a date range say 6/1/2019 to 6/1/2021
The SQL Pivot builds a series of columns that show the data related to the dates below.
Jun-19, Jul-19, Aug-19, ....... Jun-20, Jul-20, Aug-20, ....... Apr-21, May-21, Jun-21

Is this even possible. If not please let me know. Thank you. 
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial