Better formatting of stats SQL query