From the course: SQL Server Fundamentals: Master Basic Query Techniques

Unlock the full course today

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

Query processing order

Query processing order - SQL Tutorial

From the course: SQL Server Fundamentals: Master Basic Query Techniques

Start my 1-month free trial

Query processing order

- [Instructor] In the previous video, we went over the basics of how aggregate functions work, but now we need to spend a little more time on the rules for manipulating this data into a more useful structure. And here, we will consider how to order and filter results that include data from an aggregate computation. So first, let's talk about the ORDER BY clause. We've touched on it briefly before, but we need to explore it a bit further. So we have a few different options when we want to order this set. We can order by the full_name, an actual column in our table, and the set is returned alphabetized, and I could do that. As we said before, by default, it's ascending, but if I wanted to do it in reverse order, I could designate descending, and then it would be Z to A. I can also order by the aggregate function itself, so I can order by count star. Again, ascending or descending. I could order by multiple columns, the count, and then by the full name, if I wanted to do that, and then…

Contents