I have a table
|Start Date|End Date |Value|Avgerage Value Per Day|
|2011-01-01 |2012-01-01| 730 | 2|
I want to turn this table into a View
|Date| Average Value |
2011-01-01 | 2
2011-01-02 | 2
2011-01-03 | 2
…..
2011-12-31 | 2
Is is possible without using temp table to generate a list of date?
Any ideas?
Edit
Thanks both of the answers
With recursive view is similar as temp table
I do worry about the performance in a view, caz the view later will be involved in other processes.
I’ll try recursive view then, if it doesn’t fit, I may just use an hard code date list table.
Yes you can. This generates the days from the input set and then gives you the ranges you need
Though this technically internally is like temp tables you can create a recursive view :
you can the query it but you need to ensure that you specify a recursion limit
this gives this result
You can see that from the test data I wanted May 1-2 and April 1-5