Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with % Change in value in procedure

Status
Not open for further replies.

rajcs25

Programmer
May 17, 2004
1
US
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;
 
Might want to try this question in a specific database programming forum rather than General Database, looks like Transact SQL, so I recommend the Microsoft SQL Server; Programming forum.

-------------

Sometimes the grass is greener on the other side because there is more manure there - original.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top