Hi folks,
I need to display a history all our Products
we've sold by day, week, month and year. This data will be sent to google charts API to display a line graph of the results.
So if i have a table called Products
and it looks like:-
Products
ProductID INT
DateCreated DATETIMEOFFSET
and the user asks to see the history for ProductID 1. How could i retrieve this? eg output.
Graph 1 (Dates vs Sale Count)
Monday 1st Dec: 0
Tuesday 2nd Dec: 3
Wed 3rd Dec: 1
Graph 2 (Weeks vs Sale Count)
Week 49 2008: 21
Week 50 2008: 11
Week 51 2008: 45
Week 52 2008: 0
Graph3 (Months vs Sale Count)
Dec 08: 102
Jan 09: 23
I'm not sure if the 'by day' can be done ... or any of it.
cheers :)
Update 1 : got part of it working...
After spending a bit of time, i got the first one working... but still need help on the other two AND making it all part of one query...
from p in Products
where p.ProductId == 69
group p.DateCreated by p.DateCreated.Date into grouping
orderby grouping.Key
select new { Date = grouping.Key, Count = grouping.Count() }