ORDER BY | BUS 104 – SQL Exam

ORDER BY explained

Remember lining up for attendance as a kid in elementary school?

Let's say we've got the following students in a classroom…

Peter, Lila, Alex, and Bella lined up in a classroom

…and that we need them to line up for attendance in alphabetical order.

So, they scramble around until they finally get into proper order.

Alex, Bella, Lila, and Peter in alphabetical order

This is exactly what ORDER BY statements do.

ORDER BY statements are used to sort results based on a field or aggregate function.

How to code an ORDER BY

Here's the template for an ORDER BY statement:


This is the end of the preview. To unlock the rest, get the SQL Cram Kit or Lifetime Access.

Already purchased? Click here to log in.

Leave a Comment