Hello,
I would like to show the result fo each day of the past 30 days. I might not have data to display for everyday but I still want the date to show up
01/27/2007 resultA
01/28/2007 resultB
01/29/2007 .
...
02/26/2007 resultC
02/27/2007 resultD
Thanks for your help
Arnold
Could you give me an example for the table variable as I have no idea on how to build that.
Thanks
Just to give you an idea here's a sample. You might need to build your code on top of this (if this works for you).
declare @.ttable( Datecoldatetime, col2varchar(50))Declare @.mindatedatetime, @.maxDatedatetime, @.daysint,Set @.mindate ='01/27/2007'Set @.maxDate ='02/27/2007'while (datediff(d,@.mindate,@.maxdate) >= 0 )BeginInsert into @.t (Datecol, col2)Values (@.mindate )set @.mindate = @.mindate + 1--Another Query to get the results for date = @.mindateEndselect *from @.t
No comments:
Post a Comment