~/devreads

#order by

3 posts

13 Jul 2018

lukaseder 1 min read

One of the things that confuse SQL users all the time is how DISTINCT and ORDER BY are related in a SQL query. The Basics Running some queries against the Sakila database, most people quickly understand: This returns results in an arbitrary order, because the database can (and might apply hashing rather than ordering to … Continue reading How SQL…

sqldistinctdistinct onorder byorder of operations

6 Nov 2017

lukaseder 1 min read

Usually, this blog is 100% pro window functions and advocates using them at any occasion. But like any tool, window functions come at a price and we must carefully evaluate if that’s a price we’re willing to pay. That price can be a sort operation. And as we all know, sort operations are expensive. They … Continue reading How to…

sqlorder byperformancesort operationsql performance

13 May 2014

lukaseder 1 min read

SQL Server is known to have a very strict interpretation of the SQL standard. For instance, the following expressions or statements are not possible in SQL Server: Strictly speaking, that limitation makes sense because the above ROW_NUMBER() or OFFSET expressions are non-deterministic. Two subsequent executions of the same query might produce different results. But then … Continue reading SQL Server…

sqloffsetoffset paginationorder bysql server