1、使用order by关键字:
select * from emps where id > 10 order by age ASC;
2、按表达式排序:
select *, salary*12*(1+IFNULL(commission, 0)) 年薪 from emps order by salary*12*(1+IFNULL(commission, 0)) desc;
3、按别名排序:
select *, salary*12*(1+IFNULL(commission, 0)) 年薪 from emps order by 年薪 desc;
4、按函数排序:
select length(lastName) 字节长度,lastName,salary from emps order by length(lastName) desc;
5、按多个字段排序:
select * from emps order by salary asc, id desc;

1638

被折叠的 条评论
为什么被折叠?



