# Tuesday, 23 May 2006

This is a question asked of Google that led to my blog today. Of course, I haven't blogged on such a thing, but I figure what the heck? Let's do it!

For the next person that searches for such an item, the opposite of SELECT TOP is also SELECT TOP. Huh? You simply change the ORDER BY clause to be descending. For example, if you have a query such as:

SELECT TOP 10 FirstName, LastName, BirthDate

  FROM Persons

 ORDER BY LastName, FirstName

then the opposite would be:

SELECT TOP 10 FirstName, LastName, BirthDate

  FROM Persons

 ORDER BY LastName DESC, FirstName DESC

Simple, huh?

You may be asking, "What if I don't care about the order?" Then I have to say that you don't really care about TOP versus BOTTOM, either as you are going to get a random (as far as we know) set of rows in either case.

Tuesday, 23 May 2006 00:04:28 (Pacific Daylight Time, UTC-07:00)  #    Comments [3]