Refactored SQL to be more clear and shared between queries for new people.