我的表像这样的表:
id no.of sales datetime
1 14 2013-09-10
2 45 2013-09-09
3 18 2013-09-08
4 14 2013-08-12
5 15 2013-08-14
6 18 2013-07-12
在第 9 个月的上表中,有 3 行。第 8 个月有 2 条记录。我需要第 9 个月和第 8 个月的所有销售额的总和,依此类推。谁能告诉我如何实现这一点。我的查询:
DateTime frommonth = DateTime.Now.AddMonths(-3);
DateTime tomonth = DateTime.Now;
var result= from pa in cxt.Products
where (pa.datevalue >= frommonth && pa.datevalue < tomonth)
&& pa.productname == productname
orderby pa.datevalue descending
select new { noofsales=pa.No_of_sales ,datetime=pa.datevalue};
通过使用上述查询,我得到了个人第 9 个月的记录。我不想要个人的销售数量,我需要所有第 9 个月的销售额、第 8 个月的销售额等等。请告诉我...