【Mysql】获取Employees中的first_name,查询按照first_name最后两个字母,按照升序进行排列

获取Employees中的first_name

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

题目描述:获取Employees中的first_name,查询按照first_name最后两个字母,按照升序进行排列。
两种写法:
RIGHT(s,n),返回字符串 s 的后 n 个字符。

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

SUBSTR(s, start, length),从字符串 s 的 start 位置截取长度为 length 的子字符串。

select first_name
from employees
order by substr(first_name,-2,2)

Mysql常用函数:https://www.runoob.com/mysql/mysql-functions.html

牛客题霸-SQL篇【Mysql】 文章被收录于专栏

少壮不努力,老大勤刷题

全部评论

相关推荐

每晚夜里独自颤抖:这个在牛客不是老熟人了吗
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-25 19:15
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务