Hi, Don't know If I'm being dense here, but I can't seem to get my head round this...We've got a support system. Lets say for arguments sake the jobs table & data looks like this:create table #Support(jobid int identity (1,1), start datetime, complete datetime)insert into #support select '01/05/2009', '07/05/2009' unionselect '02/05/2009', '08/05/2009' unionselect '03/05/2009', '09/05/2009' unionselect '04/05/2009', '10/05/2009' unionselect '05/05/2009', '11/05/2009' unionselect '06/05/2009', '12/05/2009' unionselect '07/05/2009', '13/05/2009'
I can work out how many jobs are outstanding (not completed) at any given date like this:declare @reportdate datetimeset @reportdate = '01/05/2009'select @reportdate reportdate,count(jobid) outstandingjobsfrom #support where @reportdate >= #support.start and @reportdate <= isnull(#support.complete, current_timestamp)
Which gives me this:reportdate outstandingjobs---------- ---------------2009-05-01 1But how do I work out how many jobs are outstanding for each day within a period? so say I wanted to make my period 01/05/2009 to 13/05/2009, I want to get back something like this:reportdate outstandingjobs---------- ---------------2009-05-01 12009-05-02 22009-05-03 32009-05-04 42009-05-05 52009-05-06 62009-05-07 72009-05-08 62009-05-09 52009-05-10 42009-05-11 32009-05-12 22009-05-13 1Any ideas?CheersCheers,Yonabout