(PDB-555) All unit tests passing
(PDB-555) Small refactor to remove 1 subquery
(PDB-555) Better formatting for sql