sql - How to get monthly and quarterly data for a team -


i want able generate report shows current month of submitted surveys compared total quarter of surveys has. need statement able add monthly amounts each month report exported. know how accomplish this?

select ua.firstname     ,ua.lastname     ,count(s.year) totalstudies     ,(select count(s.year)      parentinfo p     left join survey s on p.surveyid=s.surveyid     left join cooperationlevel cl on p.surveyid=cl.surveyid     left join surveyaccess sa on p.surveyid=sa.surveyid     left join useraccount ua on sa.userid=ua.userid     s.year=year(getdate())      , (cl.cioiscooperation=1 or cl.cioispartialcooperation=1)      ,  ua.userid in (73699)     group ua.firstname,ua.lastname,sa.userid) cooperation     ,(select count(s.year) nocooperation     parentinfo p     left join survey s on p.surveyid=s.surveyid     left join cooperationlevel cl on p.surveyid=cl.surveyid     left join surveyaccess sa on p.surveyid=sa.surveyid     left join useraccount ua on sa.userid=ua.userid     s.year=year(getdate())      , ((cl.cioiscooperation=0 , cl.cioispartialcooperation=0) or cl.cioiscooperation null , cl.cioispartialcooperation null)      ,  ua.userid in (73699)     group sa.userid) nocooperation     parentinfo p     left join survey s on p.surveyid=s.surveyid     left join cooperationlevel cl on p.surveyid=cl.surveyid     left join surveyaccess sa on p.surveyid=sa.surveyid     left join useraccount ua on sa.userid=ua.userid     s.year=year(getdate())      ,  ua.userid in (73699)     group ua.firstname,ua.lastname,sa.userid 

the current query gives individual surveys not aggregate.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -