题解 | #获取employees中的first_name#

获取employees中的first_name

http://www.nowcoder.com/practice/74d90728827e44e2864cce8b26882105

主要是 sql 截取字符串方法:

从左到右截取,就用 left(field/string,length);

从右到左截取,就用 right(field/string,length);

指定位置开始截取,substring_index(str,s,count);

从字符第 count 次出现的位置开始截取字符串(count可为符负数,若找不到指定字符,则返回整个字符串)就用 substring(field/string,start,length)。 本题从右向左截取两位,作为排序依据即可:

select first_name
from employees
order by right(first_name,2) asc

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务