TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
To Find Previous Month Data With SQL Query
Vandana
Aug 16
2016
Code
629
0
2
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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