FIX: Change order of topic_tracking_state SELECT SQL (PR #13259)

This allows us to do DISTINCT on the topic_id to remove duplicates (e.g. in extensions to the report SQL), and also introduces an additional_join_sql string to allow extensions to JOIN additional tables.

GitHub