I have this query that sorts on a 2-character column. I would like to sort only on the first character of it. Is this possible using order by____.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With