我有一个带有ReportViewer
控件的ASP.NET Web窗体的ASP.NET MVC 4应用程序。我正在使用实体框架。
我想显示一个包含订单的表(id,date_add,名称,数量,价格)
1 | 2011-12-08 | apples | 4 | 0.99
2 | 2012-01-07 | oranges | 20 | 1.39
4 | 2012-03-04 | plumes | 80 | 1.59
5 | 2012-05-01 | apples | 15 | 0.89
6 | 2012-05-03 | pears | 10 | 1.29
7 | 2012-05-09 | oranges | 18 | 1.49
我希望我的报告看起来像这样:
December - Sum(price for dec 2011)
1 | 2011-12-08 | apples | 4 | 0.99
2011 - Sum(price for 2011)
January - Sum(price for jan 2012)
2 | 2012-01-07 | oranges | 20 | 1.39
March - Sum(price for mar 2012)
4 | 2012-03-04 | plumes | 80 | 1.59
May - Sum(price for may 2012)
5 | 2012-05-01 | apples | 15 | 0.89
6 | 2012-05-03 | pears | 10 | 1.29
7 | 2012-05-09 | oranges | 18 | 1.49
2012 - Sum(price for 2012)
如何使用追溯来完成?
月份是否可以崩溃,年份可见(首次运行)?
答案 0 :(得分:0)
我做了一个SP,我提取周,月和年号。来自数据 _add字段。
CREATE PROCEDURE [dbo].[Orders]
AS
SELECT id_order, data_add, order_name, quantity, price, MONTH(data_add) as Mn, YEAR(data_add) as Ye, DATEPART( wk, data_add) as Week,
FROM order
RETURN
在报告的Tablix中,我分组了2次(按月分组,然后逐年分组)。