• If I understood you correctly, your problem isn't really how to group by a date: GROUP BY [ASSIGNED] takes care of that. I'm sure you also have no problem creating a WHERE clause to select only rows with [ASSIGNED] dates in the specified range.

    Your problem is you do not want to count quantities of assigned items where they are beyond the end date. For that you need a CASE expression that only returns the value of quantities for dates prior to [ENDS].

    select Assigned, Item, SUM(case when [Assigned] <= [Ends] then Qty else 0 end) as QTY

    from @t

    join blah blah blah

    where blah blah blah

    group by Item, [assigned]

    order by Item, [assigned]

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills