• The CTE has a default max recusrion of 100. I can easily create a on the fly set of 100 consecutive days from a start date with something like :

    (using my ol favorite Northwind database)

    declare @startdate datetime='1996-07-01';

    WITH SET1 AS(

    SELECT clm1 FROM (VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) AS rs(clm1) /* TEN ELEMENTS */

    ),

    SET2 AS(

    SELECT a.clm1 FROM SET1 a, SET1 b /* 10 rows x 10 rows = 100 rows */

    )

    ,

    SET3 as

    (

    SELECT DATEADD( d, ROW_NUMBER() OVER( ORDER BY ( SELECT '1')) - 1, @startdate) AS [Date]

    fromset2

    )

    selects3.[date],

    count(orderID) numOrders

    FROMSET3 as s3

    left join Orders as o ON s3.[date] = o.orderDate

    GRoup

    Bys3.[date]

    Order by [Date];

    Here you can just join to your attendance table instead of the orders table. If you need more days create another set that takes a cross of the previous CTE (set2 in this example). Hope this makes sense.

    ----------------------------------------------------