Sql sort on first character of column Sql sort on first character of column database database

Sql sort on first character of column


The SUBSTR function can return the first character of a string.

SELECT * FROM YourTable ORDER BY SUBSTR( SomeField, 1, 1 )

SUBSTR takes three parameters, the field to sort, the 1-based start position, and the number of characters to return.

Per my comment above, I maintain that there is no meaningful difference in the output of this and

SELECT * FROM YourTable ORDER BY SomeField