C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
To Find Previous Month Data With SQL Query
WhatsApp
Vandana
Aug 16
2016
679
0
2
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
desc
DATEADD
DATEPART
Up Next
To Find Previous Month Data With SQL Query