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
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Venkat Govind
1.2k
568
67.6k
How to sum of all months value ?
May 28 2015 3:03 AM
Hi I have one Employee table jan 2015 i created 50 Employee after feb 2015 month i created 10 employee march i am not added employee list i need output of march 2015 total employee march 60
how can i do that, i am sum each month query below
select Month,Total from (select
SUM(case DATEPART(MONTH,wf.Createdate) when 1 then 1 else 0 end)as January,
SUM(case DATEPART(MONTH,wf.Createdate) when 2 then 1 else 0 end)as February,
SUM(case DATEPART(MONTH,wf.Createdate) when 3 then 1 else 0 end)as March,
SUM(case DATEPART(MONTH,wf.Createdate) when 4 then 1 else 0 end)as April,
SUM(case DATEPART(MONTH,wf.Createdate) when 5 then 1 else 0 end)as May,
SUM(case DATEPART(MONTH,wf.Createdate) when 6 then 1 else 0 end)as June,
SUM(case DATEPART(MONTH,wf.Createdate) when 7 then 1 else 0 end)as July,
SUM(case DATEPART(MONTH,wf.Createdate) when 8 then 1 else 0 end)as August,
SUM(case DATEPART(MONTH,wf.Createdate) when 9 then 1 else 0 end)as September,
SUM(case DATEPART(MONTH,wf.Createdate) when 10 then 1 else 0 end)as October,
SUM(case DATEPART(MONTH,wf.Createdate) when 11 then 1 else 0 end)as November,
SUM(case DATEPART(MONTH,wf.Createdate) when 12 then 1 else 0 end)as December
From mstr_vendor as v inner join mstr_workforce as wf on v.VendorCode=wf.VendorCode
where 1=1 and v.VendorCode='LTSBV000001' and DATEADD(D, 0, DATEDIFF(D, 0,wf.Createdate))
Between '01/01/2015' and '05/28/2015' group by v.VendorCode) p unpivot( Total for Month
IN(January,February,March,April, May,June,July,August,September,October,November,December))AS unpvt ;
Reply
Answers (
2
)
How to send the Username and password Database To User mail
Access video and audio files from other source mechine