Hi
I am trying to show a count by day from a table with an Effective Date field.
The table has different rows for each different state the item is in.
My query is something like this -
Select COUNT(Item), YEAR(EffectiveFrom), MONTH(EffectiveFrom), DAY(EffectiveFrom)
From table
Where State = IN(1,4,5)
Group By YEAR, MONTH, DAY, Count.
Current result is something like this -
Owner, Year, Month, Day, Count
A, 2010, 01, 01, 5
B, 2010, 01, 01, 6
C, 2010, 01, 01, 8
A, 2010, 01, 02, 4
B, 2010, 01, 02, 7
C, 2010, 01, 02, 7
This produces individual counts per day, but does not provide a cumulative total per day.
I am trying to achieve something like this, bearing in mind the item can change its state, thus the cumulative total does not always increase -
Owner, Year, Month, Day, Count
A, 2010, 01, 01, 5
B, 2010, 01, 01, 6
C, 2010, 01, 01, 8
A, 2010, 01, 02, 9
B, 2010, 01, 02, 13
C, 2010, 01, 02, 15
I have read some suggestions regarding the use of a temporary calendar table. Can you provide some info/advice that I should go down this route?
Any help would be greatly appreciated.
Cheers
Ted
I am trying to show a count by day from a table with an Effective Date field.
The table has different rows for each different state the item is in.
My query is something like this -
Select COUNT(Item), YEAR(EffectiveFrom), MONTH(EffectiveFrom), DAY(EffectiveFrom)
From table
Where State = IN(1,4,5)
Group By YEAR, MONTH, DAY, Count.
Current result is something like this -
Owner, Year, Month, Day, Count
A, 2010, 01, 01, 5
B, 2010, 01, 01, 6
C, 2010, 01, 01, 8
A, 2010, 01, 02, 4
B, 2010, 01, 02, 7
C, 2010, 01, 02, 7
This produces individual counts per day, but does not provide a cumulative total per day.
I am trying to achieve something like this, bearing in mind the item can change its state, thus the cumulative total does not always increase -
Owner, Year, Month, Day, Count
A, 2010, 01, 01, 5
B, 2010, 01, 01, 6
C, 2010, 01, 01, 8
A, 2010, 01, 02, 9
B, 2010, 01, 02, 13
C, 2010, 01, 02, 15
I have read some suggestions regarding the use of a temporary calendar table. Can you provide some info/advice that I should go down this route?
Any help would be greatly appreciated.
Cheers
Ted