Using DISTINCT ON in Non-PostgreSQL Databases

The DISTINCT ON gem

A nice little gem in PostgreSQL's SQL syntax is the DISTINCT ON clause, which is as powerful as it is esoteric.

In a previous post, we blogged about some caveats to think of when DISTINCT and ORDER BY are used together. The bigger picture can be seen in our article about the logical order of operations in SQL SELECT.