0
我想知道如何計算SSRS中設置的年份參數的總數。選擇一個特定年份時,前幾年的先前計數將與當前計數相加。在我的存儲過程中使用@year參數之前,它在SSRS中工作,但是這次我想嘗試對其進行硬編碼,然後在SSRS中只有一個年份參數。計算不同年份的總數
這裏是我的代碼示例,我要和目前的工作:
select
sum(MITotal.Count) as 'Yearly Count',
year(c_date) as 'year'
from
(select
count(*) as Count,
pol1.C_STATE,
month(pol1.c_Date) as Month,
year(pol1.c_ate) as Year,
left(datename(mm, C_Date), 3) + ' ' + cast(year(C_Date) as char(4)) as MonthYear
from contract pol1
where
pol1.C_STATE='wa'
group by pol1.C_STATE,month(pol1.c_Date),year(pol1.c_Date), left(datename(mm, C_Date), 3) + ' ' + cast(year(C_Date) as char(4))) MITotal
group by MITotal.Year
將返回:
2 2009
5 2010
6 2011
我怎麼會去添加到代碼,以便每當,我選擇將2010年作爲參數年,它將增加5 + 2或2011年,並且將增加5 + 6 + 2作爲總計。任何指針將不勝感激。
謝謝,我會嘗試一下! – user2146212 2013-03-19 02:20:42
是否有任何其他的方式做不使用@Year作爲我的sp裏面的參數。 – user2146212 2013-03-19 02:38:25
這取決於年份是否可計算。如果用戶選擇年份,則無法選擇,您必須將其作爲參數傳遞。如果它類似於「去年之前的每年」,那麼您可以在存儲過程中輕鬆地進行計算。 – 2013-03-19 04:47:51