SQL functions for querying the latest dates for each table.