SQL tutorial •
Lesson
24
,
Tips & Tricks

The order of the elements in your query

In this section, you’ve learned a few new elements you can add to your queries, <span class = "code">GROUP BY</span> and <span class = "code">ORDER BY</span>, on top of the <span class = "code">SELECT</span>, <span class = "code">FROM</span> and <span class = "code">WHERE</span> that were introduced earlier. The order of these elements needs to be correct for a query to run. The order in which you write your query should always be as follows:

  1. <span class = "code">SELECT</span>
  2. <span class = "code">FROM</span>
  3. <span class = "code">WHERE</span>
  4. <span class = "code">GROUP BY</span>
  5. <span class = "code">ORDER BY</span>
Next up
LIMITing the amount of data with SQL