# sqlite SELECT first_name FROM employees ORDER BY substr(first_name,length(first_name)-1) asc; SELECT first_name FROM employees ORDER BY substr(first_name,-2) asc; SELECT first_name FROM employees ORDER BY substr(first_name,length(first_name)-1,2) asc; SELECT first_name FROM employees ORDER BY substr(first_name,-2,2) asc; 本题考查 substr(X,Y,Z) 或 substr(X,Y) 函数的使用。其中X是要截取的字符串。Y是字符串的起始位置 (注意第一个字符的位置为1,而不为0),取值范围是±(1~length(X)),当Y等于length(X) 时,则截取最后一个字符;当Y等于负整数 -n 时,则从倒数第n个字符处截取。Z是要截取字符串的长度,取值范围是正整数,若Z省略,则从Y处一直截取到字符串末尾;若Z大于剩下的字符串长度,也是截取到字符串末尾为止。