ShadyBears
ShadyBears

Reputation: 4175

ORACLE SQL ORDER BY

How would I go about ordering by the last three letters of a name?

For example:

Ashley

Julia

Belvet

ley > lia > vet

Also, how would I go about doing a secondary sort by ID if the last three letters are the same (Bobby, Robby...)?

Upvotes: 2

Views: 58

Answers (1)

Robby Cornelissen
Robby Cornelissen

Reputation: 97130

For your first question:

ORDER BY SUBSTR(name, -3)

For your second question:

ORDER BY SUBSTR(name, -3), id

Upvotes: 3

Related Questions