• You got your solution, but I like to explain why your solution failed.

    The LEFT JOIN you used (in itself, without the selection on date) will produce at least one row for every row in the temp table. If there is no match, then that row will have NULL values for all columns originating from the ListDetail table.

    Adding the WHERE clause will, for those rows, result in a comparison of a NULL value to the specified date range. Such a comparison for NULL always evaluates to Unknown, and an Unknown condition in a WHERE will result in the row not being included.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/