Let’s look at our latest query with
SELECT signup_date, country, COUNT(*) AS users_count FROM users GROUP BY country, signup_date ORDER BY signup_date DESC, country ASC
As you can see we’ve duplicated country and signup_date columns 3 times . It definitely could be improved.
In programming there’s a DRY principle – Dont Repeat Yourself. It has many variations, but the idea is that the first time you need to duplicate something is OK. The second time you’re duplicating this thing it’s time to refactor the code and remove duplication.