Moved the ordering after the count as it caused an error in the sql as the column is ambiguous.