How SQL DISTINCT and ORDER BY are Related – Java, SQL and jOOQ.

One of the things that confuse SQL users all the time is how DISTINCT and ORDER BY are related in a SQL query.