Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query for totals over a rage of dates 2

Status
Not open for further replies.

scotttom

IS-IT--Management
Mar 5, 2002
143
US
I'm looking for some guidance for getting a sum of one column when certain dates match..

Basically I'm trying to map capacity usage.

I have a table like this that holds the data...

Number DateStart DateComplete
200 1/1/2011 1/3/2011
300 1/2/2011 1/4/2011


What I'm looking for is results like this...

1/1/2011 200
1/2/2011 500
1/3/2011 500
1/4/2011 200

I so frequently have gotten great techniques from this forum I thought I'd start here.

Thanks in advance.
 
what you will need is a calander table

1/1/1
1/2/1
....
12/31/12

starting as erley as yo need it as far ahead as you need

Select dayofyear ,sum(number)
From calander
inner join capacity
on dayofyear between DateStart And DateComplete
Group by dayofyear

 
Perfect. Exactly what I needed.

THanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top