public Select::orderBy($field, $direction = 'ASC')
Overrides SelectQuery::orderBy().
PostgreSQL adheres strictly to the SQL-92 standard and requires that when using DISTINCT or GROUP BY conditions, fields and expressions that are ordered on also need to be selected. This is a best effort implementation to handle the cases that can be automated by adding the field if it is not yet selected.
$query = db_select('example', 'e');
$query->join('example_revision', 'er', 'e.vid = er.vid');
$qu