From the course: Advanced SQL: Logical Query Processing, Part 1

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Ordering result sets

Ordering result sets - SQL Tutorial

From the course: Advanced SQL: Logical Query Processing, Part 1

Start my 1-month free trial

Ordering result sets

- [Instructor] I'm sure that by now you've had enough of hearing me say this, but I'm going to say it again anyway. Sets have no order. In the relational model, neither the attributes nor the tuples have any order. Their SQL counterparts, rows and columns, were not so lucky. SQL supports ordering of both rows and of referencing expressions by their ordinal position. First, let's get expression order out of the way. Most databases support referencing select list expressions using their ordinal position as they are listed from left to right. Theoretically the select clause is evaluated after the having clause, and no previous clauses should be aware of these positions. And SQL server does follow this logical order, and allows referencing expressions by position only after they are evaluated, meaning it is only allowed in the order by clause, the only clause that follows the select. Other databases include the MySQL and…

Contents