Live Webinar: Prompt Engineering: Skill Everyone Must Learn Today
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
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
666
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
DATEPART
DATEADD
Up Next
To Find Previous Month Data With SQL Query