I have an sql Table that presents historic of enegy consumption values. Now I need to perform some queries in order to get statistics by hour, day, week, month and years, Of course each one apart. An example of query is :
from c in context.ConsumptionSet
join e in context.EquipmentSet on c.EquipmentID equals e.EquipmentID
orderBy c.Date
group new { c, e } by c.Date into grp
select new
{
date = grp.Key.Day,
value = grp.GroupBy(i => i.e.EquipmentID).Sum(g => g.Max(i => i.c.Value))
})
A you can see, I want the list to be ordered by Date first ( which is of a DateTime type), and then grouped by day. However this above query did not provide me with the excepted result. What am I missing right there ?