\begin{frame}
\frametitle{Sorting Output}
If query output is to be read by humans, enforcing a certain
\emph{tuple order} helps in interpreting the result.
\begin{goal}{}
``Order by'' allows to specify a \emph{list of sorting criteria}.
\end{goal}
\pause
\smallskip
\begin{alertblock}{}
Without such an ordering, the order is \emph{unpredictable}:
\begin{itemize}
\item Depends on the internal algorithms of the query optimiser.
\item Order may change even query to query.
\end{itemize}
\end{alertblock}
\pause
\smallskip
\begin{code}{\textwidth}{}
\small
\sql{order by attribute1 [asc|desc], attribute2 [asc|desc], \ldots}
\end{code}
\begin{goal}{}
An \sql{order by} clause may specify multiple attribute names:
\begin{itemize}
\item
The second attribute is used for tuple ordering if they agree on
the first attribute, and so on (\emph{lexicographic ordering}).
\pause
\item Sort in \emph{ascending} order (default): \sql{asc},
\item Sort in \emph{descending} order: \sql{desc}.
\end{itemize}
\end{goal}
\end{frame}