• The LEFT JOIN for the derived table in the example from stuart.adair should be on b.database_name (not b.DateLogLastBackedUp):

    ) b ON a.[name] = b.database_name