select Agentname,cast(Sum(agentAmount) as int) as Tolling
from Tablename
WHERE DATEPART(m, datefieldname) = DATEPART(m, DATEADD(m, -1, getdate()))
AND DATEPART(yyyy, datefieldname) = DATEPART(yyyy, DATEADD(m, -1, getdate()))
group by agentname order by tolling descTo fetch previous month data with the help of SQL Server.
