order by random meaning (postgresql)
ORDERY BY random() is not a special case.  It generates random numbers, one for each row, and then sorts by them.  So it results in rows being presented in a random order.

Rather it is ORDER BY &lt;literal constant&gt; which is the special case, but that special case only works with integers.  It throws the error you show for non-integers.  The special case is that it uses the integer to index into the select-list, and orders by that column from the select list.  This lets you both select and order by an expression, without having to repeat the expression in both places.