title: Grouping and Ordering Columns in Sql
body: <p>I'm running into an issue that I would expect to be easy enough to figure out but for some reason I can't. I have a three column dataset which is made up of the state, county and population. In SQL, I would like to sum the total people by State and County, I would then like to group by State and County and order by Total People in descending order. This is simple enough, except I would like my dataset to first group by state and county then order, meaning if State A County A has the most Total People then all State A rows will be grouped together first.</p>
  <pre><code>    Select State, County, sum(Total_Population) as tot_pop
          from state_county_2
          group by state, county
          order by tot_pop desc, state,county ;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/DtQq7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DtQq7.png" alt="enter image description here" /></a></p>