SQL commands sequence

I knew that in SQL generally we write statements like this :

/* after creating the table */

SELECT something FROM table_name WHERE something something

or

SELECT something FROM table_name HAVING something something

The question I wanna ask is does it matter where do I put GROUP BY?

Can I add it at the end like this :

SELECT something FROM table_name WHERE something something GROUP BY something

Or I should add it in the middle?

SELECT something FROM table_name GROUP BY something WHERE something something

Does it really matter?

Thanks in advance.

@camperextraordinaire