HI folks
i have a procedure
i want to write a statement in this which displays % Change in value at #10
10. Here i want to write a statement that finds % Change in Value from 2 and 4???
look below
please help me out
create procedure whatever as
begin
1.(select NWRITTENBY AS UserInfo, tdate AS PmtDate, CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
+ ' to ' + CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) AS PreviousMTD, CONVERT(varchar(10), GETDATE() - (DATEPART(dd,
GETDATE()) - 1), 101) + ' to ' + CONVERT(varchar(10), GETDATE() - 1, 101) AS CurrentMTD
from tablename where tid=1 group by nwrittenby,tdate)
2. (select sum(pmtct) as NewCount from tablename where tid=1 and tdate between convert(varchar(10), getdate() - (datepart(dd, getdate()) -1), 101)
and convert(varchar(10), getdate() -1, 101) group by nwrittenby)
3. (select sum(pmta) as NewPmtAmt from tablename where tid=1 and tdate between convert(varchar(10), getdate() - (datepart(dd, getdate()) -1), 101)
and convert(varchar(10), getdate() -1, 101) group by nwrittenby)
4. (select sum(pmtct) as NewCountprev from tablename where tid=1 and tdate between CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
and CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) group by nwrittenby)
5. (select sum(pmta) as NewCPmtAmtPrev from tablename where tid=1 and tdate between CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
and CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) group by nwrittenby)
6. (select sum(pmtct) as ActiveCount from tablename where tid not in (0,3) and tdate between convert(varchar(10), getdate() - (datepart(dd, getdate()) -1), 101)
and convert(varchar(10), getdate() -1, 101) group by nwrittenby)
7. (select sum(pmta) as ActivePmt from tablename where tid not in (0,3) and tdate between convert(varchar(10), getdate() - (datepart(dd, getdate()) -1), 101)
and convert(varchar(10), getdate() -1, 101) group by nwrittenby)
8. (select sum(pmtct) as ActiveCountprev from tablename where tid not in (0,3) and tdate between CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
and CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) group by nwrittenby)
9. (select sum(pmta) as ActivePmtPrev from tablename where tid not in (0,3) and tdate between CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
and CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) group by nwrittenby)
10. Here i want to write a statement that finds % Change in Value from 2 and 4???
end
exec whatever;
i have a procedure
i want to write a statement in this which displays % Change in value at #10
10. Here i want to write a statement that finds % Change in Value from 2 and 4???
look below
please help me out
create procedure whatever as
begin
1.(select NWRITTENBY AS UserInfo, tdate AS PmtDate, CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
+ ' to ' + CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) AS PreviousMTD, CONVERT(varchar(10), GETDATE() - (DATEPART(dd,
GETDATE()) - 1), 101) + ' to ' + CONVERT(varchar(10), GETDATE() - 1, 101) AS CurrentMTD
from tablename where tid=1 group by nwrittenby,tdate)
2. (select sum(pmtct) as NewCount from tablename where tid=1 and tdate between convert(varchar(10), getdate() - (datepart(dd, getdate()) -1), 101)
and convert(varchar(10), getdate() -1, 101) group by nwrittenby)
3. (select sum(pmta) as NewPmtAmt from tablename where tid=1 and tdate between convert(varchar(10), getdate() - (datepart(dd, getdate()) -1), 101)
and convert(varchar(10), getdate() -1, 101) group by nwrittenby)
4. (select sum(pmtct) as NewCountprev from tablename where tid=1 and tdate between CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
and CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) group by nwrittenby)
5. (select sum(pmta) as NewCPmtAmtPrev from tablename where tid=1 and tdate between CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
and CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) group by nwrittenby)
6. (select sum(pmtct) as ActiveCount from tablename where tid not in (0,3) and tdate between convert(varchar(10), getdate() - (datepart(dd, getdate()) -1), 101)
and convert(varchar(10), getdate() -1, 101) group by nwrittenby)
7. (select sum(pmta) as ActivePmt from tablename where tid not in (0,3) and tdate between convert(varchar(10), getdate() - (datepart(dd, getdate()) -1), 101)
and convert(varchar(10), getdate() -1, 101) group by nwrittenby)
8. (select sum(pmtct) as ActiveCountprev from tablename where tid not in (0,3) and tdate between CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
and CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) group by nwrittenby)
9. (select sum(pmta) as ActivePmtPrev from tablename where tid not in (0,3) and tdate between CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - (DATEPART(dd, GETDATE()) - 1), 101)
and CONVERT(varchar(10), DATEADD(mm, - 1, GETDATE()) - 1, 101) group by nwrittenby)
10. Here i want to write a statement that finds % Change in Value from 2 and 4???
end
exec whatever;