数据
region class_month attendance
NY 12/1/2011 70444
NY 1/1/2012 70125
NY 2/1/2012 69582
NY 3/1/2012 71529
NY 4/1/2012 72468
NY 5/1/2012 67068
LA 3/1/2012 1638
LA 4/1/2012 3079
LA 5/1/2012 4205
我希望我的结果是:
region class_month attendance
NY 1/1/2012 70125
NY 2/1/2012 69582
NY 3/1/2012 71529
NY 4/1/2012 72468
NY 5/1/2012 67068
LA 1/1/2012 0
LA 2/1/2012 0
LA 3/1/2012 1638
LA 4/1/2012 3079
LA 5/1/2012 4205
询问
SELECT a.region
,a.class_month
,CASE
WHEN a.attendance IS NULL
THEN 0
ELSE a.attendance
END AS attendance -- this clearly isn't right
FROM dbo.mbo_monthly_attendance a
where class_month between '2012-01-01' and '2012-05-01'
如何在提供的日期范围内没有出勤率的月份内创建 0 出勤率的 LA 返回行?
感谢您朝着正确的方向推动。