Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select dd.YR_MONTH,
- a.dep_code,
- a.div_code,
- d.dep_name,
- actions_assigned = isnull(count(a.action_id),0)
- from DimDate dd
- Left outer join sr_assigned_to a
- on (assign_date =[DATE] or assign_date is null)
- Left outer join sr_dep_codes d
- on (d.dep_code = a.dep_code or d.dep_code is null)
- and (d.div_code = a.div_code or d.div_code is null)
- where [date] between DATEADD(m,-13,DATEADD(mm, DATEDIFF(m,0,GETDATE()), 0))
- and DATEADD(d,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))
- group by a.dep_code,
- a.div_code,
- d.dep_name,
- dd.YR_MONTH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement