One of MySQL 8's biggest improvements is the support of window functions. As I always said in conferences, there's SQL before window functions and SQL after window functions. Once you start using them, you'll use them everywhere. Some of you poor souls are unfortunate enough to be stuck on MySQL 5.7, either of your own … Continue reading Emulating Window Functions in MySQL 5.7
Tag: RANK
How to Write Efficient TOP N Queries in SQL
A very common type of SQL query is the TOP-N query, where we need the "TOP N" records ordered by some value, possibly per category. In this blog post, we're going to look into a variety of different aspects to this problem, as well as how to solve them with standard and non-standard SQL. These … Continue reading How to Write Efficient TOP N Queries in SQL
The Difference Between ROW_NUMBER(), RANK(), and DENSE_RANK()
One of the best features in SQL are window functions. Dimitri Fontaine put it bluntly: There was SQL before window functions and SQL after window functions If you're lucky enough to be using any of these databases, then you can use window functions yourself: CUBRIDDB2FirebirdH2InformixMariaDBMySQLOraclePostgreSQLSQLiteSQL ServerSybase SQL AnywhereTeradata (source here) One of the most obvious … Continue reading The Difference Between ROW_NUMBER(), RANK(), and DENSE_RANK()