Hi . I am writing sp that i will use for generating SSRS reports . In the sp , i hv passed month name as input parameter. I am able to get the required output but need to filter it based on months .i.e entries present for current month upto next 11 months should be displayed . The data that is displayed includes a propertyvisitid, a value of 0 or 1 based on full or half day , questions answered for each day and calculated percentage based on total qsns answered and another field showing data is full day complete , half day complete or full or half day incomplete . I need to filter data based on months. i dnt knw if i need to use dateadd or different function .
I am pasting my sp code as below :
USE [PSAV]
GO
/****** Object: StoredProcedure [dbo].[proc_GetReport] Script Date: 06/22/2015 10:11:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[proc_GetReport] -- proc_GetReport 6
@MonthName int
AS
BEGIN
DECLARE @temp table(categoryid int,propvisitmainid int,fullorhalfdays int,total int)
insert into @temp
select distinct ac.auditcategoryid,pv.propertyvisitmainid,pv.FullHalfDays,
-- showing no of touch points
case when pv.fullhalfdays=0 then 4
when pv.fullhalfdays=1 then 2
end as total
from auditcategories ac
left outer join AuditCategoryQuestions acq on ac.auditcategoryid=acq.auditcategoryid
left outer join auditquestionsresponse qresp on qresp.auditcategoryquestionsid=acq.auditcategoryquestionsid
left outer join PropertyVisitMain pv on pv.propertyvisitmainid= qresp.propertyvisitmainid
group by ac.auditcategoryid,pv.propertyvisitmainid,pv.fullhalfdays
select distinct propvisitmainid,fullorhalfdays,Count(*) as Touchpts,(Count(*)*100)/total as percentage,
case when Count(*)= 4 and fullorhalfdays=0 then 'FullDayComplete'
when Count(*)= 2 and fullorhalfdays=1 then 'HalfDayComplete'
when Count(*)<> 4 and fullorhalfdays=0 then 'FullDayIncomplete'
when COUNT(*)<> 2 and fullorhalfdays=1 then 'HalfDayIncomplete'
end as Data
from @temp
where fullorhalfdays is not null
group by propvisitmainid,fullorhalfdays,total
end
Pls help .. its very urgent ..