Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Show 0 if there were none for the week

$
0
0

I am running the below query which has a calendar table that joins on the field missedday and will show a count by week of number of students out during that week.  Issue I have is that if by chance (which this situation hits) there were 0 students out for a week, the query just skips showing that week.  I want it to return all weeks but return a 0 for any/all weeks where 0 students were out.  I am sure it is in my join statement (or at least I think, lol) can someone tell me what to alter to make this happen?  Also, if you need to see coding for any of the other tables etc just let me know and I will provide that as well:

SELECT 
a.studentName, 
SUM(a.abscenceCount) As Abscence_Count, 
dt.CumulativeWeek 
FROM MissedDays a
INNER JOIN dim_Date dt
ON a.MissedDay = dt.FullDate
WHERE a.MissedDay IS NOT NULL
GROUP BY dt.CumulativeWeek, 
a.studentName


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>